LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-14-2008, 04:08 PM   #1
Accrio
LQ Newbie
 
Registered: Mar 2007
Posts: 8

Rep: Reputation: 1
Problem in Expect Script


Hi All

Am facing a problem running an expect script .

The script sends a negative number . The problem is at the statement --

Example Statement

expect "abcd"
send "-1\r"

Am not able to send negative numbers , is there any other args that i should specify with send command .
The error message at the send statement is

": must be -i, -h, -s, -null, -0, -raw, -break, or --
while executing
"send "-1\r""


Thanks in advance.
 
Old 10-14-2008, 04:30 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
It's probably reading the "-" as an attempt to set a flag. Try escaping the "-":
send "\-1\r"

Here the first \ is an escape. The second one is a special character recognized by expect (and echo).

You may have to play with it a bit to get the right sequence. It may not like the quote around the first \ so you might try:
send \-1"\r"
 
Old 10-15-2008, 09:33 PM   #3
Accrio
LQ Newbie
 
Registered: Mar 2007
Posts: 8

Original Poster
Rep: Reputation: 1
Got the Solution

It works fine if i use a flag "--" with send.
send -- "-1\r"

Thanks for the reply
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Expect Script coolest Programming 7 02-16-2009 03:59 PM
Unexpected curly braces in expect script spawn command & bash suid problem slinx Programming 1 05-02-2008 01:47 PM
problem receiving output from Expect script slinx Linux - Software 4 04-30-2008 08:02 AM
Script... variables with expect? Manana Linux - Networking 1 01-19-2007 04:41 AM
CGI script problem: Send/Expect command echo on webpage rajatgarg Programming 2 07-11-2004 04:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:07 PM.

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