?
Solved

StartInfo.Arguments for the pscp Process

Posted on 2005-03-07
4
Medium Priority
?
765 Views
Last Modified: 2010-05-18
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?
0
Comment
Question by:SCMB-GMIT
  • 3
4 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 2000 total points
ID: 13474610
If arguments are wrong, pscp.exe should handle it by it's own way. But you have exception "The system cannot find the file specified." in the Start method, which doesn't care about argument values. I think it cannot find executable file. Try to run the same code without arguments and see what happens.
0
 
LVL 14

Expert Comment

by:Thandava Vallepalli
ID: 13474722
Can you paste here the output of args variable......


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

itsvtk
0
 
LVL 14

Expert Comment

by:Thandava Vallepalli
ID: 13474734
or by using Debug.Print method


Debug.Print (args)


itsvtk
0
 
LVL 14

Expert Comment

by:Thandava Vallepalli
ID: 13474745
And pscpExe variable contents also

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

itsvtk
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Planning to migrate your EDB file(s) to a new or an existing Outlook PST file? This video will guide you how to convert EDB file(s) to PST. Besides this, it also describes, how one can easily search any item(s) from multiple folders or mailboxes…
Suggested Courses

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question