Search : in
By :

How to execute an expect scripts from windows

Last answer on Apr 8, 2009 12:15:27 pm BST uma, on Jan 6, 2009 8:29:57 am GMT 
 Report this message to moderators

Hello,
It might sound silly to ask this question.but i am using this expect scripts for the first time.
so let me know how to execute an expect script.

i was tring to execute a script below.





set hostname "10.65.201.35"
set username "ftp"
set password "test123"
set target_directory "C:\expect_progs"
set build_directory "C:\Inetpub\ftproot"
set build_file "success.doc"

# 1. Set the ftp prompt using a regular expression.
set ftp_prompt "ftp>?"

# 2. Print to console.
puts stdout "Connecting to $hostname to upload the latest build."

# 3. Connect to the FTP server using the "spawn" command.

spawn ftp $hostname

# 4. Wait for a login prompt.
expect -re "(Name|login|Login|Username).*:.*" {

# 5. Login prompt received. Send user name to Unix server.
exp_send "$username\r"
exp_send_user "sent username\n"
} eof {

# 6. No login prompt received. Display an error.
exp_send_user "could not connect\n"
}

# 7. Wait for a password prompt from the Unix server.
expect "Password:" {
# 8. Password prompt received. Send the password.
exp_send "$password\r"
}

# 9. Wait for an FTP prompt. Enter FTP commands.
expect -re $ftp_prompt {
# 10. Change to the upload directory on the Unix server.
exp_send "cd $target_directory\r"
}

expect -re $ftp_prompt {
# 11. Change to the local directory you want to
# upload from (Windows machine).
exp_send "lcd $build_directory\r"
}

expect -re $ftp_prompt {
# 12. Upload the file to the Unix server.
exp_send "put $build_file\r"
}

expect -re $ftp_prompt {
# 13. Close the FTP connection to the Unix server.
exp_send "exit\r"
}

i executed this script as
tclsh filename.exp

but it was throughing and error as below.

Connecting to 10.65.201.35 to upload the latest build.
invalid command name "spawn"
while executing
"spawn ftp $hostname"
(file "file.exp" line 18)
child process exited abnormally
%
i was using the tclsh84 to execute this script.


kindly help me out and let me know were i am going wrong.


Thanks in advance!!!!

Uma

Best answers for « how to execute an expect scripts from windows » in :
Execute a script a startup and shutdown Show Execute a script a startup and shutdown The trick works Windows XP, Vista and 7, but the method varies depending on your edition of Windows. For professional or full editions Start the policy editor of the local group: Start Menu> Run> Type...
[Ubuntu] Executing a script at startup and shutdown Show [Ubuntu] Executing a script at startup and shutdown To execute a script at startup To execute a script at shutdown To execute a script at startup of Ubuntu Edit /etc/rc.local and add your commands. The script must always end with...
Batch Script - Move files to \%date%\%time%\ ShowBatch Script - Move files to \%date%\%time%\ Issue Solution Note Issue I have been trying to make a simple batch script to create database backups and move then into a folder named by date, and a sub folder by time. This is what I...
Activating Java script for Youtube ,Metacafe , ShowActivating Java script for Youtube ,Metacafe Issue Solution For FireFox Issue When trying to view an online video on YouTube , you are prompted to activate your Java Script or to download the latest version of adobe flash player , in...
[Ubuntu 9.04] Plan a visual message Show[Ubuntu 9.04] Plan a visual message Intro Getting started Preparing the script Planning the execution of script Adding an icon to the message Intro Ubuntu 9.04 has a new application that manages the notification system: notify-osd ,...
Download Application as Service ShowApplication as Service is tool to run an executable application as Windows service. The program supports 32/64-bit application and does not require a user session. The user will be able to create, edit, visualize and manage Windows services from a...
Download Aqua Data Studio ShowAqua Data Studio is an advanced SQL editor. It can create, edit and execute SQL scripts. This software provides an integrated database with only one interface for connecting to databases. Query Analyzer enables users to work on RDBMS synthax and auto...
Wowexec - wowexec.exe Showwowexec - wowexec.exe wowexec.exe (wowexec stands for Window On Window Execution) is a Windows NT/2000/XP generic process used for providing support for outdated 16-bit Windows applications. The process wowexec is launched from the NTVDM service....
User management in Windows NT ShowThe notion of a user Windows NT is an operating system which manages sessions, meaning that when the system is started, it is necessary to log in with a user name and password. When Windows NT is installed, the administrator account is created by...
File sharing in Windows XP ShowAdvantages File sharing involves making the content of one or more directories available through the network. All Windows systems have standard devices making it easy to share the content of a directory. However, file sharing may lead to security...

1

neeks78, on Jan 6, 2009 9:11:27 am GMT
  • +1

Hi,
i was passing by when i noticed something which can help you.
it is the user's guide of how to use the expect script
try this link:
http://gid.cimne.upc.es/ManHtml/tcl8.4.12/expect4win/expect.­html

Reply to neeks78

2

 kannan, on Apr 8, 2009 12:15:27 pm BST
  • +1

Hi Uma,

I too facing the same issue.If u got the answer can you forward to this mail kannanjmc@gmail.com

Thanks in Advance
N.kannan.

Reply to kannan