Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

OK, it's PowerShell, so use the syntax you are already using for example with -filemask=:
"cd `"`"/Covid Reports`"`""`

Even that is shown at the article, I've pointed you to above already:
https://winscp.net/eng/docs/commandline#syntax
vmedhe

Hey Martin,
I actually tried that but it did not work. Instead I still get the error below. I will post the full code now to see if it maybe shows the issue usernames, keys, passwords, are scrubbed. It seems to file trying to find the Covid report file and still thinks its only named /Covid.


Searching for host...
Connecting to host...
Authenticating...
Using username "user".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Session started.
Active session: [1] activesession@ftp.fake.com
Error changing directory to '/Covid'.
Cannot get real path for '/Covid'.
The file path does not exist or is invalid.
Error code: 10
Error message from server (en-US): Unable to resolve path
/
cd /Outgoing/Immunization
lcd ""\\aicps01\home\PSfiles\Medicat""
exit
Error

& "C:\Program Files (x86)\WinSCP\WinSCP.com" `
  /log="\\aicfs01\SAIC\users\vmedhe\thing.log" /ini=nul `
  /command `
    "open sftp -hostkey=`"`"hostkey=`"`"" `
   "cd ""/Covid Reports"""`
   "lcd `"`"\\aicps01\home\PSfiles\COVID`"`"" `
        "get -filemask=`"`">today`"`" *.*" `
   "cd /Outgoing/Immunization" `
   "get -filemask=`"`">today`"`" SAIC_Notcompliant_*.txt" `
   "lcd `"`"\\aicps01\home\PSfiles\Medicat`"`"" `
        "get -filemask=`"`">today`"`" *.*" `
    "exit"
 
$winscpResult = $LastExitCode
if ($winscpResult -eq 0)
{
  Write-Host "Success"
}
else
{
  Write-Host "Error"
}
 
exit $winscpResult
vmedhe

Using CD command when there is a space. ERROR "Too many parameters for command 'cd'."

Hey all this seems to be a pretty simple one but there seems to be nothing on here about how to fix it save one post with no examples.

I am using WinSCP and a generated URL in PowerShell to fire this off. But when I try to change directories I get the error:
Too many parameters for command 'cd'.

This is where I want to go:
"cd /Covid Reports"`

The space is of course the issue and everyone keeps telling me to double quote it. But that does not seem to work. Obliviously im doing it wrong but have no clue HOW im doing it wrong, any advice or if someone could put the fix and explain the double quotes everyone is talking about that would be nice.