LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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-01-2010, 12:50 PM   #1
KBUTLER1
LQ Newbie
 
Registered: Apr 2010
Posts: 1

Rep: Reputation: 0
Unhappy new to expect, thrown into fire


Hi im trying to write an expect script using telnet, first one worked then asked to do this one help!

i need to cycle power on and off and put a message of pass or fail in the message but continue to cycle the power

this is what i have so far....i know im missing something or all of it
thanks for you help...

source ./SMS_TAH_procs_bootcheck.exp
global CP_Mac
global CP_Port
global ipTermServ
global portNum
global my_debug

proc main {{cycle 1} {start_step 0} uut_id temp_id power_id} {
global my_debug
set my_debug 1


set timeout -1
###################################################
#
# 0 power cycle on off
#
###################################################

if {$start_step <= 0} {
puts "Starting Step 0 - CYCLE $cycle - [timestamp -format "%X, %b %d %Y"]\r"
cycle_test 1 $uut_id $power_id
sleep 3
}


set pass_in [lindex $argv 0]
set step_in [lindex $argv 1]
set fail_in [lindex $argv 2]

if {$pass_in < 1} {set pass_in 1}
if {$step_in < 1} {set step_in 1}
if {$fail_in < 1} {set step_in 1}

set uut_id [open_port "10.0.0.42" 2001]
set power_id [open_port "10.0.0.41" 23]



if {$pass_in == 1} {
puts "[timestamp -format " Cycle $pass_in, Step $step_in: %c"]\r\n"
main 1 $step_in $uut_id $power_id

if {$fail_in ==1_ {
puts "[timestamp -format " Cycle $fail_in, Step $step_in: %c"]\r\n"
main 1 $step_in $uut_id $power_id

set step_in 1
set pass_in 2
set fail_in 3
}
 
Old 04-01-2010, 01:18 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well what's not working?? please don't expect use to just debug all your code without a decent explanation of where you're stuck. You've also clearly got a reference to an external file which isn't listed here. I can certianly see for one thing though there's no spawn, and expect is pretty useless if you don't even spawn anything to interact with.
 
Old 04-01-2010, 01:26 PM   #3
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
This is not the way to use Expect. You should not open a tcp connection on port 23, but instead you have to spawn telnet, and use the send and expect.

Google for "expect man page", there are some basic examples on that page which should get you going.

jlinkels
 
Old 04-01-2010, 02:11 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
  


Reply

Tags
expect, help, linux



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
use cdck to tell if an old CD-RW should be thrown away newbiesforever LinuxQuestions.org Member Success Stories 0 02-02-2008 03:45 PM
I want to be thrown into a distro, not skip into one... Pengers Linux - Distributions 14 08-05-2007 01:18 PM
Getting thrown into read-only mode - not able to remount dleangen Linux - General 19 06-07-2007 07:45 PM
How to replace fire fox 1.5.0.9 with fire fox2 in mepis 6.0 inspiron_Droid LinuxAnswers Discussion 0 02-21-2007 01:19 PM
LILO>GRUB and a little Drivecrypt thrown in... jgottlieb12 Linux - General 4 07-08-2005 05:52 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:10 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration