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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Special characters quote in sh 1

Status
Not open for further replies.

mrimagepueblo

Programmer
Dec 15, 2003
52
US
This one is driving me nuts. In a /bin/sh script I am trying to create a login script to a windows ftp 5.0 server from a unix box. My password is Kug.cb!\c`
That is indeed a back tick at the end. I lost track of all the combinations I have tried with \ and " and '
My last attempt doesn't give an error, or is even trying the pass $PASSWD but simply prompts for my password and then proceeds with the rest of the script:

USER='myusername'
#PASSWD="Kug"."cb"!""\"c"`""
PASSWD="Kug.cb\\\!\\c'"
ftp -n ftp.domain.com <<END_OF_SCRIPT
user $USER
pass $PASSWD
prompt off
cd ..
cd _Photos
binary
hash
mget *.zip
bye
END_OF_SCRIPT
exit 0
 
It looks like the FTP client (at least the one I tried) attempts to process backslashes, so surrounding it in single quotes should protect it from the shell, and adding a backslash should escape the backslash for the FTP client.

[tt]PASSWD='Kug.cb!\\c`'[/tt]

Using .netrc is fine of course...


Annihilannic.
 
I've should have mentioned the .netrc. I've tried that but I may not fully understand all of it's syntax. I need to get an example on a working account done first and then try your suggestion stefanwagner.
I'll have to wait until 11/25 late to try Annihilannic's solution. The system locks me out for 24 hours after 3 unsuccessful attempts. I guess I've been making this too hard perhaps.
Thanks for your posts on Thanksgiving. I'm thankful for the help and tips.
 
Thanks Annihilannic. I made it way too hard. Only the backslash needed backslahed :) I thought the ! and ` (tick) needed it as well. Thanks a million.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top