LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-19-2010, 07:01 AM   #1
MeenakshiPrasanna
LQ Newbie
 
Registered: Nov 2010
Posts: 6

Rep: Reputation: 0
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

Last edited by MeenakshiPrasanna; 11-19-2010 at 07:09 AM.
 
Old 11-19-2010, 07:20 AM   #2
MeenakshiPrasanna
LQ Newbie
 
Registered: Nov 2010
Posts: 6

Original Poster
Rep: Reputation: 0
when i tried to connect thru shell prompt its connecting.
but thru shellscript no luck

please help me.
 
Old 11-19-2010, 07:40 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by MeenakshiPrasanna View Post
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.
 
Old 11-19-2010, 07:56 AM   #4
MeenakshiPrasanna
LQ Newbie
 
Registered: Nov 2010
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by TB0ne View Post
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
 
Old 11-19-2010, 08:04 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by MeenakshiPrasanna View Post
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?
 
1 members found this post helpful.
Old 11-19-2010, 08:19 AM   #6
MeenakshiPrasanna
LQ Newbie
 
Registered: Nov 2010
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by catkin View Post
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
 
Old 11-19-2010, 08:23 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
OK -- that's doing it manually. What about running the script and running the script by the sh command?
 
1 members found this post helpful.
Old 11-19-2010, 08:30 AM   #8
MeenakshiPrasanna
LQ Newbie
 
Registered: Nov 2010
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by catkin View Post
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.
 
Old 11-19-2010, 08:41 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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.

Last edited by catkin; 11-19-2010 at 08:43 AM. Reason: #/!/bin/bash -> #!/bin/bash
 
1 members found this post helpful.
Old 11-19-2010, 10:25 AM   #10
MeenakshiPrasanna
LQ Newbie
 
Registered: Nov 2010
Posts: 6

Original Poster
Rep: Reputation: 0
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.
 
Old 11-19-2010, 01:08 PM   #11
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by MeenakshiPrasanna View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] shell script using wget to download files from ftp, sub directories bayaraa_u Linux - General 1 04-28-2010 02:50 AM
shell script required to get the mail after files are uploaded to ftp siddabathuni Programming 12 10-01-2009 08:08 AM
shell script - auto ftp files that older than 60 days bakeng Linux - Newbie 2 12-25-2007 10:35 PM
FTP files to remote server with a shell script Pezzoni Linux - Software 2 06-27-2007 07:01 AM
Running FTP inside Shell Script truncates files jbhanc0125 Red Hat 3 01-16-2004 11:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration