Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

white spaces in directory name

Status
Not open for further replies.

gsapl

Programmer
Feb 20, 2008
1
CA
Hi Guys,

I am new to Perl and writing a script where I have to use 'Program files' directory, but the script (obviously) doesn't recognize the white space between 'program' and 'files'. Here's what I am doing:

system("c:\program files\ipswitch\ws_ftp progressional\ftpscrpt.com -f abc.scp");

What I am doing wrong here?

Thanks in advance.

Gsap
 
try single quotes instead of double-quotes. The backslashes are not being interpreted as file path delimiters but as escape characters so what you have is:

c:program filesipswitchws_ftp progressionalftpscrpt.com

or something close to that

run you program with warnings turned on:

use warnings;

better yet, use forward slashes in the path, Windows fully supports forward slashes:

c:/program files/ipswitch/ws_ftp progressional/ftpscrpt.com

that avoids the issue all together

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
but the script (obviously) doesn't recognize the white space between 'program' and 'files'
You're being presumptious. The spaces are largely irrelevant, it's the backslashes that are causing the problem.

One word of advice: if you think you know what's causing the problem in a given situation, try to set up another situation that's absolutely identical apart from that problem (i.e. try for another directory that doesn't contain spaces). Doing that will indicate that it's not the spaces that's the problem.

Another hint: Regardless of what OS you're running, perl will also accept a forward slash (/) as a directory separator. It's usually advisable to use that in all cases apart from presenting directory/file paths to users.
 
Don't try forward slashes in DOS though.



------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top