By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,852 Members | 2,259 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,852 IT Pros & Developers. It's quick & easy.

Folder name with "&" not getting created with ssh in perl

P: 3
Hi All,
I am trying to create a folder with "&" in itz name (Ex: TS_&_ABC) with the help of perl's ssh command in another server. The exact command I am triggering in the code is

ssh("-i",$identity_file,"abc.abc.net","mkdir -p /opt/abc/mailboxes/mail/TS_&_ABC");

This creates a folder "TS_" but throws up an error
sh: line 1: _ABC: command not found.

We have already tried enclosing the folder name with single-quotes like
ssh("-i",$identity_file,"abc.abc.net","mkdir -p /opt/abc/mailboxes/mail/'TS_&_ABC'");

Apart from this we had also tried by putting a backslash before the "&"
But no use.

Please help how we can escape the "&" symbol in the perl's ssh command.

Thanks in advance

Regards,
Anand.
Aug 8 '08 #1
Share this Question
Share on Google+
4 Replies


P: 14
Hi Anand,

Escaping with backslash is working fine when I tried on my SSH

-Chiku
Aug 8 '08 #2

P: 14
Hi Anand,

Try escaping "&" with \backslash

Expand|Select|Wrap|Line Numbers
  1. mkdir TS_\&_ABC
You need to escape with \backslash when you want to remove this dir.

-Chiku
Aug 8 '08 #3

P: 3
I tried out as u said , with a backslash.

ssh("-i",$identity_file,"abc.abc.net","mkdir -p /opt/abc/mailboxes/mail/TS_\&_ABC");

It made no difference ,it created a folder TS_

and throwed up an error as _ABC command not found.

Please revert with suggestions.

regards
sudarshan
Aug 8 '08 #4

KevinADC
Expert 2.5K+
P: 4,059
as suggested on another forum, try using two backslashes:

\\&_ABC"
Aug 8 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.