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.e xe -pw "xxxxxxxxxx" -i "C:\Utils\Putty\keys\swart m.ppk" "C:\work\Murex\GL Feed\MURFI_PATH\newDoc.txt " "mxeqd@mxdev02.scmb.co.za: //uddapp01 /app/murex /mxeqd01_l nk/murfi/r eader/data "
My code is as follows:
string pscpExe = @"z:\Murex\Utils\pscp\pscp .exe";
string passPhrase = "xxxxxxxxxx";
string keyPath = @"C:\Utils\Putty\keys\swar tm.ppk";
string destPath = "mxeqd@mxdev02.scmb.co.za: //uddapp01 /app/murex /mxeqd01_l nk/murfi/r eader/data ";
Process pscpProcess = new Process();
pscpProcess.StartInfo.File Name = pscpExe;
filePath = filePath.Replace("\\\\","\ \");
string args = "-pw " + "\"" + passPhrase + "\"" + " -i "+ "\"" + keyPath + "\"" + " " + "\"" + filePath + "\"" + " " +
"\"" + destPath +"\"";
pscpProcess.StartInfo.Argu ments = 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 ://uddapp0 1/app/mure x/mxeqd01_ lnk/murfi/ reader/dat a\"".
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?
My bat file that does the same thing, contains the following:
z:\Murex\Utils\pscp\pscp.e
My code is as follows:
string pscpExe = @"z:\Murex\Utils\pscp\pscp
string passPhrase = "xxxxxxxxxx";
string keyPath = @"C:\Utils\Putty\keys\swar
string destPath = "mxeqd@mxdev02.scmb.co.za:
Process pscpProcess = new Process();
pscpProcess.StartInfo.File
filePath = filePath.Replace("\\\\","\
string args = "-pw " + "\"" + passPhrase + "\"" + " -i "+ "\"" + keyPath + "\"" + " " + "\"" + filePath + "\"" + " " +
"\"" + destPath +"\"";
pscpProcess.StartInfo.Argu
pscpProcess.Start();
When I watch the args parameter, the value is "-pw \"xxxxxxxxxx\" -i \"C:\\Utils\\Putty\\keys\\
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or by using Debug.Print method
Debug.Print (args)
itsvtk
Debug.Print (args)
itsvtk
And pscpExe variable contents also
Debug.Print( pscpExe )
Debug.Print( args )
itsvtk
Debug.Print( pscpExe )
Debug.Print( args )
itsvtk
string args = "-pw " + "\"" + passPhrase + "\"" + " -i "+ "\"" + keyPath + "\"" + " " + "\"" + filePath + "\"" + " " +
"\"" + destPath +"\"";
System.Console.WriteLine( args );
itsvtk