LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 07-01-2010, 01:27 PM   #1
Kof
LQ Newbie
 
Registered: Jul 2010
Posts: 3

Rep: Reputation: 0
test ftp connection after grepping out hostname


Hi guys,

I am in the middle of trying to write my first script. I have created
a command using sed and grep to grab a list of ftp hosts from a host file. Now I want to test the ftp connection of the hosts that have been returned after running the command.

grep host config.xml | sed 's/<//g;s/>//g;s/host//g;s/[/]//g' | sort | uniq -d | ftp ftp.hostname.com

I get the below error

Unknown AUTH type.
Unknown AUTH type.
KERBEROS_V4 rejected as an authentication type
Password:Name (ftp.hostname.com:username):

Any feedback will be much appreciated
 
Old 07-01-2010, 01:33 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
well what feedback do you want, and what test do you want to perform? Ultimately the script appears to work - you've cleary got no way to enter usernames and passwords in that one liner, so naturally the ftp server is going to need authentication.
 
Old 07-01-2010, 04:07 PM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,167

Rep: Reputation: 889Reputation: 889Reputation: 889Reputation: 889Reputation: 889Reputation: 889Reputation: 889
scp with keys will probably give you more mileage.
 
Old 07-02-2010, 08:10 AM   #4
Kof
LQ Newbie
 
Registered: Jul 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Hi Guys, Thansk for yor reply . apologies for not making this sound clear. So basically I want to be able to test the connection to all the ftp host that has been outputed. I dont need to log in to the ftp host, I am after a "connected" reply just like if I ran the ftp command from a command line. see example below

$ ftp ftp.hostname.com
Connected to ftp.hostname.com.
220 Newedge ftp service
504 Unknown AUTH type.
504 Unknown AUTH type.
KERBEROS_V4 rejected as an authentication type
Name (ftp.hostname.com:user):

Does that help?
 
Old 07-02-2010, 08:42 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
i'd use nmap in that case, it'd give you very simple non-interactive scan over a range of addresses and be able to do some basic ftp interaction to validate a level of availability. curl could also be useful, I certainly would use the ftp client itself.
 
Old 07-02-2010, 10:27 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,564

Rep: Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901
Not to be too picky and I know you are new, but the grep really is unnecessary.
If you can give us a demo of the xml line containing what you want, your sed can probably be tidied up too
 
Old 07-19-2010, 03:10 PM   #7
Kof
LQ Newbie
 
Registered: Jul 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Hi Guys,

Sorry for late reply, I had some personal issues to deal with.

I have a text file that has a list of FTP hostnames, I want to create a script that will read each line that has the FTP address, and then test the FTP connection using NETCAT. I then want to publish the result of the test (output) in another file, showing SUCCESS or FAILURE next to each FTP site that has been tested.

Does that make sense?
 
Old 07-19-2010, 08:11 PM   #8
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,564

Rep: Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901
Yes it makes sense, although does not appear to be what you demonstrated in your original question.

Based on your last post the pseudo code would be:

loop over file with hostnames
netcat each address from file and test for success
redirect output to a new file
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Test hostname Zeno McDohl Linux - Newbie 12 12-17-2007 08:08 AM
Cannot SSH/FTP by hostname, but ip works joshtt Linux - Networking 3 09-20-2005 06:08 AM
hostname while on a wireless connection CoonerTheRed Linux - Newbie 0 10-15-2004 11:38 AM
Do after changed the hostname, can't connection by SSH again? explorer1979 Linux - Networking 2 03-30-2004 11:15 PM
How do you change the hostname and will can you ftp to it? ibm5_25 Linux - Networking 1 12-28-2003 03:17 AM

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

All times are GMT -5. The time now is 04:13 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration