doing scp from java when file has spaces in it

Ladner, Eric (Eric.Ladner) Eric.Ladner at
Tue Sep 9 05:44:31 EST 2003

Did you try this:

scp  [...options]  "/vhosts/dw02411/tmp_daemon/1020046111/Lots of spaces
text.txt" grt0002d at

(although, I'm surprised the one with single quotes failed).

What OS is this on?  What command line shell?  Escaping of spaces is
depending on the environment you are in, not what kind of scp binary you
use.  The first, third and fourth examples should have worked in a
Bourne shell, Korn shell or BASH (I think).


-----Original Message-----
From: Vinit Khandelwal [mailto:vinit.k at] 
Sent: Friday, September 05, 2003 12:42 AM
To: openssh-unix-dev at
Subject: doing scp from java when file has spaces in it


I am new to scp. I am trying to scp a file from local (m/c) to remote
through a java application running in Tomcat.

When I try to upload a file with no spaces in it, it works. But if
spaces are present (file name is : "Lots of spaces text .txt") it is not

Some of the things I tried are mentioned below and they failed. 

scp  [...options]  '/vhosts/dw02411/tmp_daemon/1020046111/Lots of spaces
text .txt' grt0002d at 

scp  [...options]  /vhosts/dw02411/tmp_daemon/1020046111/Lots\\ of\\
spaces\\ text\\ .txt grt0002d at 

scp  [...options]  /vhosts/dw02411/tmp_daemon/1020046111/Lots\ of\
spaces\ text\ .txt grt0002d at 

scp  [...options]  /vhosts/dw02411/tmp_daemon/1020046111/"Lots of spaces
text .txt" grt0002d at 

scp  [...options]  /vhosts/dw02411/tmp_daemon/1020046111//"Lots of
spaces text .txt/" grt0002d at 

Is there any other way of running the command for scp from java

Thanks in advance.

Disclaimer: The information in this e-mail and any attachments is
confidential / privileged. It is intended solely for the addressee or
addressees. If you are not the addressee indicated in this message, you
may not copy or deliver this message to anyone. In such case, you should
destroy this message and kindly notify the sender by reply email. Please
advise immediately if you or your employer does not consent to Internet
email for messages of this kind.

openssh-unix-dev mailing list
openssh-unix-dev at

More information about the openssh-unix-dev mailing list