LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Issue with ftp (Windows NT) via SHELL SCRIPT to get files. (https://www.linuxquestions.org/questions/linux-newbie-8/issue-with-ftp-windows-nt-via-shell-script-to-get-files-845293/)

MeenakshiPrasanna 11-19-2010 07:01 AM

Issue with ftp (Windows NT) via SHELL SCRIPT to get files.
 
Hi Everyone,

I have an issue with shell script
#! /usr/bin/ksh

HOST=myhost
USER=myuser
PASSWD=myuser
ftp -nv <<EOF
open $HOST
user $USER $PASSWD
bye
EOF

when i run this shell to test connection from unix machine to unix ftp it works fine. but when the target ftp server is Windows NT
it gives the following error

[test@testserver test]$ sh test.sh
Connected to SERVER.
220 Microsoft FTP Service
500 'AUTH GSSAPI': command not understood
500 'AUTH KERBEROS_V4': command not understood
KERBEROS_V4 rejected as an authentication type
331 Password required for myuser.
530 User myuser cannot log in.
Login failed.
221

Please let me know is there any problem with the script/server.

Thanks
Meenakshi

MeenakshiPrasanna 11-19-2010 07:20 AM

when i tried to connect thru shell prompt its connecting.
but thru shellscript no luck

please help me.

TB0ne 11-19-2010 07:40 AM

Quote:

Originally Posted by MeenakshiPrasanna (Post 4164297)
when i tried to connect thru shell prompt its connecting.
but thru shellscript no luck
please help me.

Don't bump your own thread after 20 minutes. We volunteer here, and answer when we can (and when we feel like).

There is no problem with your script, but there appears to be a problem with the Windows FTP server. Start there. Look at the Windows FTP logs. Pay particilar attention to the very obvious errors you're getting:
Quote:

500 'AUTH GSSAPI': command not understood
500 'AUTH KERBEROS_V4': command not understood
KERBEROS_V4 rejected as an authentication type

Indicating authentication errors. Try using expect in your script instead, and see if that works.

MeenakshiPrasanna 11-19-2010 07:56 AM

Quote:

Originally Posted by TB0ne (Post 4164321)
Don't bump your own thread after 20 minutes. We volunteer here, and answer when we can (and when we feel like).

There is no problem with your script, but there appears to be a problem with the Windows FTP server. Start there. Look at the Windows FTP logs. Pay particilar attention to the very obvious errors you're getting:

Indicating authentication errors. Try using expect in your script instead, and see if that works.


Hello

Thanks for the reply i din bump the thread unecessarily i just tried ftp command thru shell prompt and it got connected so jus thought it would be helpful for anaysing the problem. by the way EXPECT din work for me.

Thanks Again

catkin 11-19-2010 08:04 AM

Quote:

Originally Posted by MeenakshiPrasanna (Post 4164297)
when i tried to connect thru shell prompt its connecting.

So let's look for what's different. Please connect from the command prompt again and run the script again and copy and paste what you see into this thread, removing confidential data. That way we can see exactly what you see.

Which shell are you using at the command prompt? How did you create the script -- was it a Windows editor?

What happens if you run the script by sh yourscript.sh?

MeenakshiPrasanna 11-19-2010 08:19 AM

Quote:

Originally Posted by catkin (Post 4164340)
So let's look for what's different. Please connect from the command prompt again and run the script again and copy and paste what you see into this thread, removing confidential data. That way we can see exactly what you see.

Which shell are you using at the command prompt? How did you create the script -- was it a Windows editor?

What happens if you run the script by sh yourscript.sh?

[test@testserver]$ ftp XX.XX.XXX.com
Connected to XX-XX-proxy2.XX.XXX.XXX.
220 Microsoft FTP Service
500 'AUTH GSSAPI': command not understood
500 'AUTH KERBEROS_V4': command not understood
KERBEROS_V4 rejected as an authentication type
Name (XX.XX.XXX.com:test): myuser
331 Password required for myuser.
Password:
230-Welcome to XX.XX.XXX.com FTP
230 User myuser logged in.
Remote system type is Windows_NT.
ftp> bye

this is the output i get.
its bin/bash. i had created the script thru windows text editor but i used dos2unix command before i ran this script.

Thanx a lot for the reply

catkin 11-19-2010 08:23 AM

OK -- that's doing it manually. What about running the script and running the script by the sh command?

MeenakshiPrasanna 11-19-2010 08:30 AM

Quote:

Originally Posted by catkin (Post 4164360)
OK -- that's doing it manually. What about running the script and running the script by the sh command?


[test@testserver]$ sh test.sh
Connected to XX-XX-proxy2.XX.XXX.XXX.
220 Microsoft FTP Service
500 'AUTH GSSAPI': command not understood
500 'AUTH KERBEROS_V4': command not understood
KERBEROS_V4 rejected as an authentication type
331 Password required for myuser.
530 User myuser cannot log in.
Login failed.
221

im not running the script thru any cron tab just im calling it in another shell script.but for testing i wrote it seperately in test.sh.

catkin 11-19-2010 08:41 AM

The purpose of the sh was to stop the #!/bin/ksh being actioned. It appears that the same commands work at the command prompt but not when run in a script so I'm trying to find the significant difference. One difference between running the script and entering the same commands at the command prompt is that the script is run using ksh (any specific reason for that? You could try using #!/bin/bash).

Another possibility was (or is -- the dos2unix command may not have been effective ...?) that the commands are not the same. You could try the od command to see exactly what is in the file, like this:
Code:

c@CW8:/tmp$ od -c test.sh
0000000  #  !      /  u  s  r  /  b  i  n  /  k  s  h  \n
0000020  \n  H  O  S  T  =  m  y  h  o  s  t  \n  U  S  E
0000040  R  =  m  y  u  s  e  r  \n  P  A  S  S  W  D  =
0000060  m  y  u  s  e  r  \n  f  t  p      -  n  v      <
0000100  <  E  O  F  \n  o  p  e  n      $  H  O  S  T  \n
0000120  u  s  e  r      $  U  S  E  R      $  P  A  S  S
0000140  W  D  \n  b  y  e  \n  E  O  F  \n
0000153

You could create a test2.sh, preferably in a non-Windows editor, and copy from the command prompt into it.

MeenakshiPrasanna 11-19-2010 10:25 AM

I tried with bash also and i created new file in vi editior n executed but still the problem exists.
Mean while the same script i tested in 2 other unix to windows FTP server there it works fine.
I guess there is some problem with the ftp server firewall settings.
Anyways, Thanks for the replies.
It helped me to debug the issue.

catkin 11-19-2010 01:08 PM

Quote:

Originally Posted by MeenakshiPrasanna (Post 4164482)
I guess there is some problem with the ftp server firewall settings.

Not convinced; how would the firewall be able to tell the difference between FTP packets generated by script or at the command prompt? Weird.


All times are GMT -5. The time now is 09:21 PM.