LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 07-01-2010, 12: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, 12:33 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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, 03:07 PM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
scp with keys will probably give you more mileage.
 
Old 07-02-2010, 07: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, 07:42 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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, 09:27 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
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, 02: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, 07:11 PM   #8
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

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



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

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

All times are GMT -5. The time now is 01:26 AM.

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