1833187 Members
3215 Online
110051 Solutions
New Discussion

Re: ftp process

 
sathis kumar
Frequent Advisor

ftp process

Hello,

Having problems while using ftp command. My user id is:sathis\$sps07 (NT server). I am trying to do ftp a file from a HP-UX server to a Windows NT server.

ftp -nv <open
user sathis\$sps07
quit
EOF

If I try the above then the 'login failed' error is coming though the logon details are correct. It is taking the user name as 'sathis$sps07' instead of 'sathis\$sps07'. Could you please help me in correcting this problem?

Thanks.
25 REPLIES 25
Ivan Krastev
Honored Contributor

Re: ftp process

Try to escape both symbols \\and \$.

Send username : 'sathis\\\$sps07'

regards,
ivan
OFC_EDM
Respected Contributor

Re: ftp process

Are you calling this from a script?

Are you doing scriptname to execute?

I'd suggest using sftp instead.

Better yet scp.

This is key authenticated and you won't be entering passwords anywhere in plain text.

Can manually run ftp and login with the username and password?
The Devil is in the detail.
OFC_EDM
Respected Contributor

Re: ftp process

Do you need the \ at all?

I thought the format was

user

Cheers
The Devil is in the detail.
sathis kumar
Frequent Advisor

Re: ftp process

I am using this in a script and we need to use ftp only for this case. I have tried giving the username as 'sathis\\\$sps07' also.

ftp -i -n << EOF
open
user sathis\\\$sps07
quit
EOF

is giving error as
User 'sathis$sps07' can not login..It still takes as 'sathis$sps07' instead of 'sathis\$sps07'.


OFC_EDM
Respected Contributor

Re: ftp process

In the end I think FTP is a bad idea. Who knows who's sniffing the line for your passwords.

I really encourage you to look at SSH and the SFTP / SCP options.

Cheers
The Devil is in the detail.
OFC_EDM
Respected Contributor

Re: ftp process

Take the slash out and put in a space.

when you put a variable beside a slash add the braces.

${variable}
The Devil is in the detail.
Rasheed Tamton
Honored Contributor

Re: ftp process

Hi,

>ftp -i -n << EOF
open
user sathis\\\$sps07
quit
EOF

ftp -i -n server name<< EOF
user sathis passwd
ls
quit
EOF

rgds.
sathis kumar
Frequent Advisor

Re: ftp process

Hi Kevin,

Could you please let me know how I should give the userid ?
Rasheed Tamton
Honored Contributor

Re: ftp process

It works on HP-UX.

ftp -i -n servername<< EOF
user satis \$sps07
dir
quit
EOF
Rasheed Tamton
Honored Contributor

Re: ftp process

I have tested it on Windows also and it works fine:

ftp -i -n << EOF
open ntservername
user satis \$sps07
status
pwd
quit
EOF


rgds.
sathis kumar
Frequent Advisor

Re: ftp process

Hi Rashid,

It is not working.
OFC_EDM
Respected Contributor

Re: ftp process

sathis,

You can hardcode the username in the script as you're doing now.

But I looked at Rasheeds post which runs on HP-UX. He has a space after the username and before the \. Maybe that's your issue.

Unfortunately I don't have a system to test.
But I don't think you need the \ at all.

user username password <-- put spaces in
or try your original line but with a space

user username \password <--Like Rasheeds script

You can pass the username as a variable as well just like the password.

For instance if you don't want to store either the user's name or password in the script you can type both in after the script name

scriptname.sh kevin kevinspassword

My username will be passed as $1
My password will be passed as $2

So your script could look like

ftp -nv <open
user $1 $2 (I didn't put he \ in but try it)
quit
EOF

Wish I had a system to test this for you.

If you put the \ in then try
user ${1} \${$2}

Good luck,
Kevin

I'll keep monitoring your post for further questions :)
The Devil is in the detail.
Dennis Handly
Acclaimed Contributor

Re: ftp process

>My user id is: sathis\$sps07

If your ID has "\" and "$" you would have to quote each. Or you tell the shell to not treat characters special by quoting the here document word:
ftp -nv <<\EOF
open
user sathis\$sps07
quit
EOF
OFC_EDM
Respected Contributor

Re: ftp process

Denis is right too.

I assumed $sps07 was a variable. But if the $ is part of the password you will have to quote it.

Also you don't need the \ look at this post

http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1234898

Regards,
Kevin
The Devil is in the detail.
OFC_EDM
Respected Contributor

Re: ftp process

Regarding the \ if that's part of your password then you need it...but quote it as per Denis's post.

Just ensure you have a space between the username and password.
The Devil is in the detail.
Rasheed Tamton
Honored Contributor

Re: ftp process

Hi Sathis

I have tested it on both HP and Win.

on my post, I took

username as satis
and passwd as $sps07

and I used a backslash char to escape the $ sign in the passwd as below and between the username and passwd there is a space.

user satis \$sps07

sathis kumar
Frequent Advisor

Re: ftp process

Thanks Dennis and all for your help.

Below code works:

ftp -nv << \EOF
open
user sathis\\$sps07
EOF

1) \ - is added with EOF 2) \ is added in username as sathis\\$sps07 (though the user name is sathis\$sps07)
OFC_EDM
Respected Contributor

Re: ftp process

Didn't have enough coffee today I guess

I was treating sathis as the username and $sps07 as the password.

Glad you got it going.

Cheers
The Devil is in the detail.
Rasheed Tamton
Honored Contributor

Re: ftp process

All the time I was also thinking username as satis and $sps07 as the password

OFC_EDM
Respected Contributor

Re: ftp process

Thankfully Dennis came along :)


The Devil is in the detail.
Dennis Handly
Acclaimed Contributor

Re: ftp process

>Kevin: Thankfully Dennis came along :)

I still don't understand why that "//" is needed in the here document. I suppose you could use tusc to figure it out.
OFC_EDM
Respected Contributor

Re: ftp process


I don't know either Dennis.

I'd like sathis to try the script without the \\ and use the double quotes around the username and password to see if that works.

But how will the script interpret the \ ?. Maybe the \ is needed after all.

But I'm curious if it work without the extra \ and use double quotes like this

ftp -nv << \EOF
open
user "sathis$sps07" ""
EOF

But now I'm thinking it does need to be escaped (\'d) because the user command is and FTP command and not shell interpretation.

Cheers
The Devil is in the detail.
Dennis Handly
Acclaimed Contributor

Re: ftp process

Looking at the here document temp file and changing the above ftp to just cat, I see the single backslash in the file if there is only one backslash in the here document.

So either you aren't using a real shell or there is something special about ftp.
Dennis Handly
Acclaimed Contributor

Re: ftp process

>Kevin: I'd like sathis to try the script without the \\ and use the double quotes around the username and password to see if that works.

It works.

In fact with only one backslash I get this error:
331 Password required for sathis\$sps07.

But only if I put double quotes around the user name. But the shell doesn't need the extra backslash.