Contents » Troubleshooting » FAQ (Frequently Asked Questions) »

How do I use scripting command working with filename containing spaces from command line?

Simple answer is that you cannot.

To work with filename containing spaces, you need to enclose the filename into double-quotes. Also individual commands containing spaces specified using command-line parameter /command need to be enclosed into double-quotes (and any scripting command working with files include at least one space to separate command name from its parameters). Implementation of command-line parsing in Windows cannot handle such double double-quoting.

You can always use script file as a replacement.

If you still need to pass the filename from command line, you can create wrapper batch file (.bat):

set FILE_TO_UPLOAD=%1
winscp.com /script=script.txt

With script.txt looking like:

open user@example.com
put %FILE_TO_UPLOAD%
exit

If you name the file put.bat, you can call it like:

put.bat "file with spaces.dat"

With some limitation you can even avoid using the wrapper batch file with construct like:

echo put "file with spaces.dat" | winscp.com user@example.com

or

echo put "file with spaces.dat" | winscp.com /command "open user@example.com" "option transfer ascii"

Note that commands passed from redirected input (via pipe |) are processed only after commands passed from command-line. Also exit command is not required as the processing ends with end of redirected input.

If your environment does not allow using batch files or internal commands (like echo) directly, you would need to execute them indirectly via Windows command interpreter (cmd.exe) like:

cmd.exe /c echo put "file with spaces.dat" | winscp.com /command "open user@example.com"
 
  faq_script_quote.txt · Last modified: 10 Apr 2008 11:15 by 193.179.225.19 (prikryl)
 

Site Search

This page

Donate

Donate via PayPal

Associations

Webhosting phpBB
Hosted by SourceForge Bookmark Manager
Driven by DokuWiki

Site design by Black Gate

Promotion consulting by TechWeb Media