john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

Linux script ftp non interactive mget subdirs

BEST ANSWER: wget -r ftp://user:pass@192.168.1.20/directory/*

OTHERWISE...

ftpls.sh

!/bin/sh

ftp -n 192.168.1.20 << EOT user username password dir $1 quit EOT

subdirs.sh

!/bin/sh

./ftpls.sh | grep ^d | awk '{print $9}'

this calls the above script to get the dir listing to stdout

then piped to grep to get directory lines

then piped to awk to only display the 9th column, dir names

for line in $( ./ftpls.sh $1 | grep ^d | awk '{print $9}') do ./ftpls.sh $1/$line | grep ^d | awk '{print $9}' done

has to be modified to do a recursive depth first search?


  • « Linux script programming
  • Linux script continued »

Published

Feb 6, 2010

Category

linux

~90 words

Tags

  • ftp 6
  • interactive 4
  • linux 249
  • mget 1
  • non 5
  • script 19
  • scripts 63
  • subdirs 3