Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
FTP app in Wish

Posted by neo (The Architect), 1 February 2005
This code here logs me into the ftp server but I am unable to execute any commands after that. The command Code:
exp_send "ls -l\r"
is not show on the screen and there is no more output after that either (even though I waited a long time).
Code:
    spawn ftp;
    set ftpPid $spawn_id;
    puts stdout "id= $ftpPid"
    expect -re ".*ftp> "
    exp_send -i $ftpPid "open $McName\r";
    expect {
       -re "Connected .*Name .*" {}
       -re "$McName:.*" {return -1}
    }

    exp_send -i $ftpPid "$UserName\r"
    expect "sword:"
    exp_send -i $ftpPid "$UserPass\r"
    expect -re ".*ftp> "
    exp_send "ls -l\r"

Any idea what is wrong with this?

Posted by admin (Graham Ellis), 1 February 2005
1. Have you tried adding another expect for "ftp> " at the end of your script; it's possible that you're sending the ls but not waiting for any response from it .... I don't know where your program goes after this, but it's a common mistake to send a command then exit leaving the child process (ftp in your case) high and dry.

2. You should never end an expected regular expression with .* as you're likely to get inconsistent results in use.   Sometimes it will match the complete response string and at other times just a part of it - it totally depends on how busy your systems are and what you swapping algorithms are doing at the time, and bugs based on this are nasty to find.   I don't think it's the cause of the current problem, but I feel that I must warn you about it.

Posted by neo (The Architect), 1 February 2005
Thanks, Will try and let you know.

How do i match those expressions then?

Posted by neo (The Architect), 1 February 2005
Ok that worked fine. I next tried a exp_send "bye\r" command and exited by my script didn't
( i tried waiting for "221 Goodbye\.\r" )



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho