Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ftp script to extract file from Lynix to WinXP PC 1

Status
Not open for further replies.

vakrig

MIS
Feb 7, 2003
3
US
I need help in starting a batch job to extract a file from my lynix server via telnet to copy a file to my hard drive.

Currently I am manually executing the following:

1. Envoke MS Dos
2. type ftp 192.168.0.1
3. login:usera
4. password:quant
5. type cd /g1/lab
6. type binary
7. get (file name)-changes every week
8. type exit
9. type quit

Thanks
Vince
 
1)Download tcl/tk or perl or python from activestate.
2)Buy a beginners book on that language.
3)Write your script. If you get stuck, write back, posting
to the language forum for your selected language.

In Tcl:
Code:
#::tclsh
package require ftp
##setup
set target [lindex $argv 0]
set bsize 2048
set tout 55

proc prompt {msg} {
 puts -nonewline stdout $msg
 flush stdout

   if {[set uout [gets stdin]] > 0} {
      return $uout
   }
return 0
}

proc mproggy {curr} {
global bsize
   puts -nonewline stdout "#"
   flush stdout
   catch {uplevel #0 "set transferred $curr"}
}

##All done

#main()
set name [prompt "Enter username: "]
set pass [prompt "Enter Password: "]
   #open session
   if {![string length $target]} {
      error "NO server specified"
   } else {
      if {![catch {set ftphandle [::ftp::Open $target $name $pass -blocksize $bsize -timeout $tout       -progress mproggy]} err_open]} {
         ::ftp::Type $ftphandle [prompt "Transfer type(ascii|binary): "]
         ::ftp::Get  $ftphandle [prompt "Filename to retrieve: "]
         ::ftp::Close $ftphandle
      }
   catch {puts $err_open}
   }
catch {puts "Transfer: $transferred"}
puts "Goodbye!"
exit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top