People
I'm having a problem making a string from a number of variables (I've
simplified the stuff below) then executing it, and have tried a number of
permutations but can't make it work.
First, double-quoting:
$command="isql -Uuser -Ppassword -SSERVER-i`"C:`\temp`\tmpLoadTran.sql`""
$command
isql -Uuser -Ppassword -SSERVER-i"C:\temp\tmpLoadTran.sql"
invoke-expression $command
Invoke-Expression : Incomplete string token.
At line:1 char:18
+ invoke-expression <<<< $command
Next, single-quoting
$command='isql -Uuser -Ppassword -SSERVER-i"C:\temp\tmpLoadTran.sql"'
$command
isql -Uuser -Ppassword -SSERVER-i"C:\temp\tmpLoadTran.sql"
invoke-expression $command
Invoke-Expression : Incomplete string token.
At line:1 char:18
+ invoke-expression <<<< $command
Then, reduce the path and double-quote:
isql -Uuser -Ppassword -SSERVER-i"tmpLoadTran.sql"
invoke-expression $command
Invoke-Expression : Incomplete string token.
At line:1 char:18
+ invoke-expression <<<< $command
Then, reduced path and single quotes:
$command='isql -Uuser -Ppassword -SSERVER-i"tmpLoadTran.sql"'
$command
isql -Uuser -Ppassword -SSERVER-i"tmpLoadTran.sql"
invoke-expression $command
Invoke-Expression : Incomplete string token.
At line:1 char:18
Finally, reduced path, single quotes and no suffix:
$command='isql -Uuser -Ppassword -SSERVER-i"tmpLoadTran"'
$command
isql -Uuser -Ppassword -SSERVER-i"tmpLoadTran"
invoke-expression $command
Unable to open input file 'tmpLoadTran'.
Finally, that 'Unable to open~~~' is from Sybase.
What do I need to do to my expression including the path and the suffix so
that invoke-expression runs it? Or can I not use invoke expression like
this? Are there any alternatives?
Thanks in advance for any clues or ideas.
Jacques


