Shell Script to ftp from windows server

Hello All,

I've to write a shell script to transfer some files to/from windows server.

I can put & get files simply by doing ftp but need to automate this.

So I tried for this -.

HOST=.hostname
USER='username'
PASSWD='***'

ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
mput new*
quit

END_SCRIPT

as per search on this topic.

But I'm getting the error :

'AUTH GSSAPI': command not understood
'AUTH KERBEROS_V4': command not understood
KERBEROS_V4 rejected as an authentication type
User ced-aswhec-ftp cannot log in.
mput new.sh? Please login with USER and PASS.
Passive mode refused. Turning off passive mode.
Please login with USER and PASS.
ftp: bind: Address already in use
mput newest.sh? Please login with USER and PASS.
mput newestt.sh? Please login with USER and PASS.

Does anyone have idea what exactly it mean? It's not accepting the valid username & password provided. Even let me know where the .netrc comes in picture...

Thanks in advance.

  • Ships

Put the user and password in your $HOME/.netrc file.

machine hostnameofmachine
login username
password passwordstring
chmod 0600 $HOME/.netrc

also, use "prompt" before using "mput" otherwise it may ask for confirmation.

Thanks Porter, for the valuable suggestion. Got to know the concept n use of .netrc file.
But still i'm getting the same error. Is there anything that need to add to my script code for making the script to use the .netrc file or by default it looks into that only?

Regards,
Shilpa

do

ls -ld $HOME/.netrc

so we can see the permissions

post exactly what you are doing and results (we should now not see anything about username/password).

what system are you using? post result of "uname -a"

Yeah, Porter,
The system I'm using is GNU/Linux

& the code now goes like :

Now I'm having the hostname entry in .netrc file having permissions as

-rw------- i.e.as per the "chmod 0600 $HOME/.netrc" mentioned by u.

The result is as :

'AUTH GSSAPI': command not understood
'AUTH KERBEROS_V4': command not understood
KERBEROS_V4 rejected as an authentication type
User ced-aswhec-ftp cannot log in.
Login failed.
Interactive mode off.
Please login with USER and PASS.
Passive mode refused.  Turning off passive mode.
Please login with USER and PASS.
ftp: bind: Address already in use

Even tried by using

But came up with same result.

Thanks n Regards,
Shilpa

You should just be able to do

ftp server-name

where server-name is exactly the same string as in $HOME/.netrc

Yes the attributes of $HOME/.netrc look right.

When it fails, is it printing the name of the user as read from $HOME/.netrc.

Don't use "-n", this disables the auto-login.

1 Like

Hi porter...

It works fine....is there a way where I can FTP without having to do anything on the .netrc file...In my case there was no .netrc file in my home directory so I created it.

thanks

Hi Porter,
Had to leave yesterday hastly, so couldnt reply.
Well,the problem still persist. Just wonder why....n yeah,after it fails, it picks username from .netrc file only. n even have disabled the -n option.

Hi Porter,
Had to leave yesterday hastly, so couldnt reply.
Well,the problem still persist. Just wonder why....n yeah,after it fails, it picks username from .netrc file only. n even have disabled the -n option.
Suprises me the error :

Thanks n Regards,
Shilpa Rajput