LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-03-2007, 03:40 PM   #1
kristof_v
Member
 
Registered: Feb 2006
Location: Belgium
Distribution: Debian
Posts: 84

Rep: Reputation: 15
expect (Tcl) question


hi,

I'm playing a bit around with expect.
connecting to a ftp server goes great with the following except script:

PHP Code:
spawn ftp ftp.somewhere.com
expect 
"Name" 
send "somebody\r" 
expect "Password:" 
send "secret\r" 
interact 
now I have a wrapper script to create an ftp user.
an ftp user can be created like this: ./ftpadmin create

then it prompts this:

PHP Code:
Create new FTP user

Username

Password:
Enter it again
so I edited the expect script like this:

PHP Code:
spawn ./ftpadmin create
expect 
"Username: "
send "jos\r"
expect "Password: "
send "test\r"
expect "Enter it again: "
send "test\r" 
This seems to go well until this line: expect "Enter it again: "
This is the output will in debug mode:

PHP Code:
expect version 5.42.1
argv
[0] = expect  argv[1] = -d  argv[2] = aftp.exp
set argc 0
set argv0 
"aftp.exp"
set argv ""
executing commands from command file aftp.exp
spawn 
./ftpadmin create
parent
waiting for sync byte
parent
telling child to go ahead
parent
now unsynchronized from child
spawn
returns {29452}

expectdoes "" (spawn_id exp6match glob pattern "Username: "no

expect
does "\u001b[H\u001b[2J" (spawn_id exp6match glob pattern "Username: "no
Create 
new FTP user

expect
does "\u001b[H\u001b[2JCreate new FTP user\r\n" (spawn_id exp6match glob pattern "Username: "no


expect
does "\u001b[H\u001b[2JCreate new FTP user\r\n\r\n" (spawn_id exp6match glob pattern "Username: "no
Username
:
expectdoes "\u001b[H\u001b[2JCreate new FTP user\r\n\r\nUsername: " (spawn_id exp6match glob pattern "Username: "yes
expect
set expect_out(0,string"Username: "
expectset expect_out(spawn_id"exp6"
expectset expect_out(buffer"\u001b[H\u001b[2JCreate new FTP user\r\n\r\nUsername: "
sendsending "jos\r" to exp6 }

expectdoes "" (spawn_id exp6match glob pattern "Password: "no
jos

expect
does "jos\r\n" (spawn_id exp6match glob pattern "Password: "no
Password
:
expectdoes "jos\r\nPassword: " (spawn_id exp6match glob pattern "Password: "yes
expect
set expect_out(0,string"Password: "
expectset expect_out(spawn_id"exp6"
expectset expect_out(buffer"jos\r\nPassword: "
sendsending "test\r" to exp6 }

expectdoes "" (spawn_id exp6match glob pattern "Enter it again: "no
test

expect
does "test\r\n" (spawn_id exp6match glob pattern "Enter it again: "no
expect
timed out
send
sending "test\r" to exp6 
someone any idea???
I really need to get this working

grtz N`Kr1pt
 
Old 04-04-2007, 02:17 AM   #2
kristof_v
Member
 
Registered: Feb 2006
Location: Belgium
Distribution: Debian
Posts: 84

Original Poster
Rep: Reputation: 15
problem solved
I threw in some sleep commands to keep the expect script from getting ahead of itself
 
Old 01-24-2013, 05:32 AM   #3
Neer
LQ Newbie
 
Registered: Jul 2010
Location: Bhopal,India
Posts: 1

Rep: Reputation: 0
Having same issue

Hi,
I also getting same error while trying to synk expect from a automated script .
cat u please tell me how did u resolved the problem????????




set argc 1
set argv0 "package.expect"
set argv "8_2_0_0d6d6"
executing commands from command file package.expect
spawn ./package.sh
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {118451}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TCL/expect - parent hangs when child dies Hewson Programming 1 03-27-2007 08:44 PM
expect question deiussum Programming 0 08-05-2005 03:51 PM
Installation of Expect 5.x tcl private headers Anarchon Linux - Software 0 07-08-2005 09:02 AM
expect question reitzell Programming 1 11-20-2004 09:03 AM
TCL, Expect, for Rsync - Please Help dholingw Programming 2 02-08-2004 10:27 AM


All times are GMT -5. The time now is 04:07 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration