0

I need lftp to connect to a list of hosts from a list file which are in ip address format. Then, if a ftp server is up, log that address (and if possible, device type, in this case routers) to a text file. For the servers that are up, I need it to connect without any credentials given and then use find to map the directories and files, then output that data to a file named after the server address. I tried to write a for loop with ftp but it was unsuccessful. I think lftp going to be the best option for what I need to do.

cat list6.txt | lftp | grep connected > livehosts.txt

also:

for i [in LIST ]; do ftp; "echo welcome> *"; done > [IP Address].txt

  • Hi! Please follow SO [How to Ask](http://stackoverflow.com/questions/how-to-ask). Give some *real* issues you're facing. – alex Jun 02 '14 at 23:20
  • I need to know what servers from my list are up and grep the output to a file. – user3701007 Jun 03 '14 at 00:34

1 Answers1

0

I need to know what servers from my list are up and grep the output to a file.

#!/bin/bash
for server in $(<list6.txt)
do  # ftp may say "Connection timed out" or "Connection refused"
    ftp $server <<<'' |& grep -q Connection || echo $server
done >livehosts.txt
Armali
  • 18,255
  • 14
  • 57
  • 171