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 :
Changing password via a script ShowChanging password via a script Method 1: passwd Method 2: chpasswd Method 1: passwd Conventionally the command use to change password on Linux based system is passwd , the option related to this command is –stdin ,an this is all...
Associating an application to a file extension ShowAssociating an application to a file extension Display all file extensions Modify an existing file association Create a new file association Manage the list of file extensions Display all file extensions Windows XP by default will mask...
Installing a SAMBA server (Linux) ShowInstalling a SAMBA server Prerequisite Introduction The Samba Architecture Installation of required packages for samba server Starting Samba The commands Smb.conf file configuration ‘’global’’ Section ‘’documents’’...
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...
Winmgmt - winmgmt.exe Showwinmgmt - winmgmt.exe winmgmt.exe (winmgmt stands for Windows Management Services) is a Windows 98/NT/Me/2000/XP generic process for creating scripts used in managing hardware, user accounts, networking, etc. The process winmgmt is not in any way a...

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

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