Home > Archive > Tcl > November 2006 > Advice needed: Problem with expect, ftp, cygwin, and Java...
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Advice needed: Problem with expect, ftp, cygwin, and Java...
|
|
| sdhiraka@gmail.com 2006-11-30, 10:06 pm |
| Hello All,
I have been tryign to get a very simple expect ftp script working in
cygwin. This script is called by a Java program, and works fine in
Linux. Under cygwin, the ftp process that is spawned by expect does
not return, even after sending in a quit command. This same script
works fine if not invoked by the Java thread.
Interestingly enough, the telnet sessions launched by my expect script
work in both cygwin and Linux environments even though they are invoked
by the Java thread.
I would like to know if anybody else has come across a similar problem,
and if there is a workaround/solution. Note that my ftp/telnet
binaries are the appropriate versions (cygwin). The execution is in
the following order:
Java thread > bash shell in cygwin > shell executes expect script >
expect launches ftp session
By looking at the process list, I can see that the system hangs waiting
for ftp to return after the binary file is successfully transfered.
Could this be a problem with cygwin's version of the GNU ftp?
Here is my short expect ftp script:
#=START SCRIPT==================
match_max 5000
set expect_out(buffer) {}
# IP address of the target
set destIP [lindex $argv 0]
# Binary file to sent to target
set binFile [lindex $argv 1]
# Logins
set ftpLogin "FTP"
set telnetLogin "root"
# Directory where the bin file will be.
set targetFTPdir "/var/ftp"
set timeout -1
set delay "0.35"
#***** Start FTP session *****
#*****************************
spawn /usr/bin/ftp $destIP
# Login
expect "$destIP*:"
send "$ftpLogin\r"
expect "ftp>"
# Transfer file
send "put $binFile\r"
expect "ftp>"
send "quit\r"
#=END SCRIPT=====================
Any info is greatly appreciated.
Regards,
Suvi D.
| |
| Gerald W. Lester 2006-11-30, 10:06 pm |
| I would tend to avoid the problem area by using the ftp package in tcllib
instead of spawning ftp.
sdhiraka@gmail.com wrote:
> Hello All,
>
> I have been tryign to get a very simple expect ftp script working in
> cygwin. This script is called by a Java program, and works fine in
> Linux. Under cygwin, the ftp process that is spawned by expect does
> not return, even after sending in a quit command. This same script
> works fine if not invoked by the Java thread.
>
> Interestingly enough, the telnet sessions launched by my expect script
> work in both cygwin and Linux environments even though they are invoked
> by the Java thread.
>
> I would like to know if anybody else has come across a similar problem,
> and if there is a workaround/solution. Note that my ftp/telnet
> binaries are the appropriate versions (cygwin). The execution is in
> the following order:
>
> Java thread > bash shell in cygwin > shell executes expect script >
> expect launches ftp session
>
> By looking at the process list, I can see that the system hangs waiting
> for ftp to return after the binary file is successfully transfered.
> Could this be a problem with cygwin's version of the GNU ftp?
>
> Here is my short expect ftp script:
>
> #=START SCRIPT==================
>
> match_max 5000
> set expect_out(buffer) {}
>
> # IP address of the target
> set destIP [lindex $argv 0]
>
> # Binary file to sent to target
> set binFile [lindex $argv 1]
>
> # Logins
> set ftpLogin "FTP"
> set telnetLogin "root"
>
> # Directory where the bin file will be.
> set targetFTPdir "/var/ftp"
>
> set timeout -1
> set delay "0.35"
>
> #***** Start FTP session *****
> #*****************************
> spawn /usr/bin/ftp $destIP
>
> # Login
> expect "$destIP*:"
> send "$ftpLogin\r"
>
> expect "ftp>"
>
> # Transfer file
> send "put $binFile\r"
> expect "ftp>"
> send "quit\r"
>
> #=END SCRIPT=====================
>
> Any info is greatly appreciated.
>
> Regards,
> Suvi D.
>
--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
|
|
|
|
|