From: Sooraj S on 27 Jul 2010 08:16 Hi, I have an expect script which uploads some data to an FTP server... I wanted to put a whole directory as such into it. But i couldn't find any commands for that. (Is there any ftp command for it...?) So i am creating the directory and then putting all the files using ftp command "mput".. code ---------------- #change pwd to $data on local machine process "$prompt" "lcd $data\r" #create directory $data on remote machine process "$prompt" "mkdir $data\r" #put all the files in $data on local machine into $data on remote. process "$prompt" "mput *\r" #wrong while loop while {expect "?"} { send "y\r" } For each and every files that need to be transfered, ftp will prompt like this "mput <file-name>?"..Is there any way to handle this (using while loop)..
From: Bruce on 27 Jul 2010 09:36 Sooraj S wrote: > Hi, > > I have an expect script which uploads some data to an FTP server... > > > I wanted to put a whole directory as such into it. > But i couldn't find any commands for that. (Is there any ftp command > for it...?) > So i am creating the directory and then putting all the files using > ftp command "mput".. > > > code > ---------------- > #change pwd to $data on local machine > process "$prompt" "lcd $data\r" > #create directory $data on remote machine > process "$prompt" "mkdir $data\r" > #put all the files in $data on local machine into $data on remote. > process "$prompt" "mput *\r" > > #wrong while loop > while {expect "?"} { > send "y\r" > } > > For each and every files that need to be transfered, ftp will prompt > like this > "mput <file-name>?"..Is there any way to handle this (using while > loop).. you can wrap the expect ina normal while loop and set some condition to break out - but expect itself can be used as a loop by using the exp_continue command inside a match body expect { "?" { send "y\r" exp_continue } eof { puts "ftp done" } } Bruce
From: Gerald W. Lester on 27 Jul 2010 09:56 Sooraj S wrote: > Hi, > > I have an expect script which uploads some data to an FTP server... > > > I wanted to put a whole directory as such into it. > But i couldn't find any commands for that. (Is there any ftp command > for it...?) > So i am creating the directory and then putting all the files using > ftp command "mput".. > > > code > ---------------- > #change pwd to $data on local machine > process "$prompt" "lcd $data\r" > #create directory $data on remote machine > process "$prompt" "mkdir $data\r" > #put all the files in $data on local machine into $data on remote. > process "$prompt" "mput *\r" > > #wrong while loop > while {expect "?"} { > send "y\r" > } > > For each and every files that need to be transfered, ftp will prompt > like this > "mput <file-name>?"..Is there any way to handle this (using while > loop).. No need to use expect, just use plain Tcl with the FTP package from TclLib or Tcl with the FTP VFS. -- +------------------------------------------------------------------------+ | Gerald W. Lester, President, KNG Consulting LLC | | Email: Gerald.Lester(a)kng-consulting.net | +------------------------------------------------------------------------+
From: Tcl Bliss on 27 Jul 2010 14:18 On Jul 27, 5:16 am, Sooraj S <soorajspadmanab...(a)gmail.com> wrote: > Hi, > > I have an expect script which uploads some data to an FTP server... > > I wanted to put a whole directory as such into it. > But i couldn't find any commands for that. (Is there any ftp command > for it...?) > So i am creating the directory and then putting all the files using > ftp command "mput".. > > code > ---------------- > #change pwd to $data on local machine > process "$prompt" "lcd $data\r" > #create directory $data on remote machine > process "$prompt" "mkdir $data\r" > #put all the files in $data on local machine into $data on remote. > process "$prompt" "mput *\r" > > #wrong while loop > while {expect "?"} { > send "y\r" > > } > > For each and every files that need to be transfered, ftp will prompt > like this > "mput <file-name>?"..Is there any way to handle this (using while > loop).. "prompt off" or "toggle prompt" or just "prompt" command will disable interactive prompting, no need for while loop. Check which command works for you.
From: sc on 10 Aug 2010 19:13 Sooraj S wrote: > Hi, > > I have an expect script which uploads some data to an FTP server... > > I wanted to put a whole directory as such into it. > But i couldn't find any commands for that. (Is there any ftp command > for it...?) believe it or not, mkdir is a valid ftp command > So i am creating the directory and then putting all the files using > ftp command "mput".. > > code > ---------------- > process "$prompt" "lcd $data\r" #change pwd to $data on > local machine you'll want to start your ftp session here > process "$prompt" "mkdir $data\r" #create directory $data on > remote machine > process "$prompt" "mput *\r" #put all the (only) files > in $data on local machine into > > $data on remote machine > > #wrong while loop > while {expect "?"} { # logic is that for > each and every files needs to be > transfered, > ftp will prompt like this "?".. > send "y\r" > } > > is there any way to handle this (using while loop).. not sure you need a loop at all -- if you're using mput, won't they all just go? sc
|
Pages: 1 Prev: using while in expect Next: Parser tools : "expected start <= end for range" |