Question : Using shell with redirection

The following shell command runs fine:
 
1:
shell  """" & strFTPPathFileName & """ -noagent -batch -P 22 -pw pw -b """ & Application.CurrentProject.Path & "\ScriptFile.txt"" [email protected]"""

The string expands to:
 
1:
"C:\WINDOWS\system32\PSFTP.Exe" -noagent -batch -P 22 -pw pw -b "C:\Documents and Settings\Administrator\My Documents\JANE'S FILES\Databases\MVRRH\ScriptFile.txt" [email protected]

The program PSFTP.exe runs and does what it is supposed to do.

However when I add redirection like this:
 
1:
shell  """" & strFTPPathFileName & """ -noagent -batch -P 22 -pw pw -b """ & Application.CurrentProject.Path & "\ScriptFile.txt"" [email protected] >""" & Application.CurrentProject.Path & "\psftpOutput.txt"""

which expands to this:
 
1:
"C:\WINDOWS\system32\PSFTP.Exe" -noagent -batch -P 22 -pw pw -b "C:\Documents and Settings\Administrator\My Documents\JANE'S FILES\Databases\MVRRH\ScriptFile.txt" [email protected] >"C:\Documents and Settings\Administrator\My Documents\JANE'S FILES\Databases\MVRRH\psftpOutput.txt"

PSFTP.exe does not run. I do not get an error in the shell command.  A cmd window opens momentarily but PSFTP.exe does not run.

When I paste the expanded string in the last code window (with the redirection) into a cmd window (via Run, cmd), PSFTP.exe runs correctly and its output goes to the redirected file.

I need help formatting the shell command line with redirection (the third code window.)

Note: Dos commands cannot use the apostrophe so I cannot replace embedded quotation marks with apostrophes.

Answer : Using shell with redirection

Hi Jaffer,

I am running in the same problems trying to pipe to findstr then redirect that output to a file. Nice try though.

This has become a moot point since I found a SFTP utility, winscp (at winscp.net) that supports scripting from a DOS call and will output to a log file.  Sample DOS call:
ret = Shell ("C:\Program Files\WinSCP\WinSCP.exe /script= """ & Application.CurrentProject.Path & "\ScriptFile.txt"" /log= """  & Application.CurrentProject.Path & "\WinSCPOutput.txt""")

I will divide the points between gustav and jaffer to close this question. Thanks quys for your trys
Random Solutions  
 
programming4us programming4us