Link to home
Start Free TrialLog in
Avatar of SCMB-GMIT
SCMB-GMIT

asked on

StartInfo.Arguments for the pscp Process

Hi Experts,

My bat file that does the same thing, contains the following:

z:\Murex\Utils\pscp\pscp.exe -pw "xxxxxxxxxx" -i "C:\Utils\Putty\keys\swartm.ppk" "C:\work\Murex\GL Feed\MURFI_PATH\newDoc.txt" "mxeqd@mxdev02.scmb.co.za://uddapp01/app/murex/mxeqd01_lnk/murfi/reader/data"


My code is as follows:

string pscpExe = @"z:\Murex\Utils\pscp\pscp.exe";
string passPhrase = "xxxxxxxxxx";
string keyPath = @"C:\Utils\Putty\keys\swartm.ppk";
string destPath = "mxeqd@mxdev02.scmb.co.za://uddapp01/app/murex/mxeqd01_lnk/murfi/reader/data";

Process pscpProcess = new Process();
pscpProcess.StartInfo.FileName = pscpExe;
filePath = filePath.Replace("\\\\","\\");

string args = "-pw " + "\"" + passPhrase + "\"" + " -i "+ "\"" + keyPath + "\"" + " " +  "\"" + filePath + "\"" + " " +
                    "\"" + destPath +"\"";
pscpProcess.StartInfo.Arguments = args;
pscpProcess.Start();


When I watch the args parameter, the value is "-pw \"xxxxxxxxxx\" -i \"C:\\Utils\\Putty\\keys\\swartm.ppk\" \"C:\\work\\Murex\\GL Feed\\MURFI_PATH\\gl_JSE 2_15_2005 3_46_59 PM.dat\" \"mxeqd@mxdev02.scmb.co.za://uddapp01/app/murex/mxeqd01_lnk/murfi/reader/data\"".

But when Start method is called, an exception is thrown: "The system cannot find the file specified."
I think what happens, is that the escape sequences are not interpreted. So, there is a lot of extra slashes in the string.

Does anyone have any ideas how to get this working?
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can you paste here the output of args variable......


string args = "-pw " + "\"" + passPhrase + "\"" + " -i "+ "\"" + keyPath + "\"" + " " +  "\"" + filePath + "\"" + " " +
                    "\"" + destPath +"\"";
System.Console.WriteLine( args );

itsvtk
or by using Debug.Print method


Debug.Print (args)


itsvtk
And pscpExe variable contents also

Debug.Print( pscpExe )
Debug.Print( args )

itsvtk