return = WSHShell.run (puttydir & "pscp.exe -batch -r " & localdir & "
" & puttysess & ":" & remotedir & " > C:\output.log",2,true)
Where return will check for a bool if the shell command ran
successfully, the pipe > works for the ping command, but when I run it
for pscp I receive an error.
This is what I'm running for ping:
return = WSHShell.run ("cmd /c ping nasctxtest >" & outputfile,2,true)
This is what i'm trying for pscp:
localdir = "C:\fromdir"
puttysess="sessionid"
remotedir="/remote/dir"
return = WSHShell.run ("C:\scripts" & "pscp.exe -batch -r " & localdir
& " " & puttysess & ":" & remotedir & " > C:\output.log",2,true)
(1) you should WScript.Echo or MsgBox the command to .Run
localdir = "C:\fromdir"
puttysess="sessionid"
remotedir="/remote/dir"
sCmd = "C:\scripts" & "pscp.exe -batch -r " & localdir _
& " " & puttysess & ":" & remotedir & " > C:\output.log"
return = WSHShell.run( sCmd, 2, true )
then you'll see mistakes like
"C:\scripts" & "pscp.exe ..." ==> "C:\scriptspscp.exe"
(missing "\")
(2) You need a shell ("cmd /c" or better "%comspec% /c") like in your
return = WSHShell.run ("cmd /c ping nasctxtest >" & outputfile,2,true)
line to get device rerouting. So prepend this to sCmd
Redirections are handled by the Command Processor. Pspc.exe
knows nothing about such things. Try this instead:
Set exec1Obj = wshShell.Exec("cmd.exe /c c:\scripts\pscp.exe .... >
c:\process1.txt")
You're probably short of a backslash too. Instead of writing
"C:\scripts" & "pscp.exe" you may want to write
"C:\scripts\pscp.exe "
There is no need to break up the string in the middle.
I would use %comspec% /c to run the *.exe. The command processor provides
the redirection capability. You also may be missing a trailing backslash in
your path to the executable. Perhaps:
return = WSHShell.Run("%comspec% /c c:\scripts\pscp.exe - batch -r " _
& localdir & " " & puttysess & ":" & remotedir & " > c:\output.log", 2,
True)
You also might want to echo the command to the command prompt to make sure
it is what you intend:
localdir = "C:\fromdir"
puttysess="sessionid"
remotedir="/remote/dir"
cmd = "%comspec% /c c:\scripts\pscp.exe - batch -r " _
& localdir & " " & puttysess & ":" & remotedir & " > c:\output.log"
Wscript.Echo cmd
return = WSHShell.run(cmd)
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
On Mar 31, 11:22 am, "Richard Mueller [MVP]" <rlmueller-
nos...@ameritech.nospam.net> wrote:
> <requ...@gmail.com> wrote in message
> --- Hide quoted text -
>
> - Show quoted text -