Archive: Problem with ExecWait and osql.exe


Problem with ExecWait and osql.exe
I'm trying to execute the following:


ExecWait '"osql.exe" -S SERVER -U USER
-P PASSWORD -n -i validate_osql.sql > validateOSQL.dat -b' $OUT


But this is not working. The $OUT variable is set to 1 after execution.

I have copied the exact command to a cmd window and it works fine. Also executing sqlplus commands works perfectly too.

Any ideas?

What doesn't work?


Originally posted by RobGrant
What doesn't work?
Sorry, I should've been more specific. The actual execution of the osql.exe command doesn't work, ExecWait works fine. When I do the following it works fine:


ExecWait '"sqlplus.exe" USER/PASSWORD@DATABASE @validate_sqlplus.sql'


Thanks.

Are you using the split line in the actual code? If so, you want to put a \ at the end of the first line so it carries over properly.


Originally posted by RobGrant
Are you using the split line in the actual code? If so, you want to put a \ at the end of the first line so it carries over properly.
No, the code is all on one line.

So what happens? Does the ExecWait DOS box appear? Does the call itself fail, or the osql program within it? Are you checking the exact commandline call, so that you can make sure it's not just a syntax error?


Originally posted by RobGrant
So what happens? Does the ExecWait DOS box appear? Does the call itself fail, or the osql program within it? Are you checking the exact commandline call, so that you can make sure it's not just a syntax error?
The ExecWait DOS box appears for a split second (too short to see what the output is). Also to check the syntax, I have copied the command within the quotes and pasted it into a command window and this works perfectly! I'm really stumped as to what's going wrong.

Hm, I bet it's the output redirection that's the problem. Try without the "> validateOSQL.dat -b", see what happens.


Originally posted by RobGrant
Hm, I bet it's the output redirection that's the problem. Try without the "> validateOSQL.dat -b", see what happens.
You're right Rob, got it to work. Using the -o option now with osql. Suppose I should've used that from the start!

Thanks again.

Hehe that's ok :) There is a way to get it to work with the > though, you just need to mess around with quotation marks to get it to work.


I am having the same problem, but I do not use output redirection. As RobGrant, I paste the command in a DOS shell and it works as it should. What can I do?

The command is: 'FOR /F $\"tokens=1,*$\" %i IN ($\'at$\') DO IF %~nxj EQU limpabd.sh.bat at %i /DELETE'

It is a loop to remove specific agended tasks.
Thanks any help.


try to prefix that command with: cmd.exe /c
you really should use nsExec or one of the other "Dos" exec plugins


Ok, I will download and use it at once. I will give a try to your tip, thanks very much! :-D