It is currently Fri, 25 Jul 2014 06:39:29 GMT



 
Author Message
 How to use echo in an expect-script
hi ngs,

I've got a big (?) problem that nobody seems be able to solve:

I wanna use the 'echo'-command of the Unices within an expect-script
but it doesn't work. I tried things like these:

1. expect1.2> spawn echo "string\r" > /dev/ttyS0
    > /dev/ttyS0 ing
   31900

2. expect1.3> spawn 'echo "string\r" > /dev/ttyS0'
    > /dev/ttyS0'
   couldn't execute "'echo": no such file or directory
   while executing
   "spawn 'echo "m\r" > /dev/ttyS0'"

3. expect1.5> spawn "echo "string\r" > /dev/ttyS0"
   extra characters after close-quote
   while compiling
   "spawn "echo "m\r" > /dev/ttyS0"..."

The purpose is an ineractice communication with another pc, thus I
need expect but I also need echo because 'send' only send to the
invoked prozess:(

Can you please help me?

Thanks in advance

Regards, Martin



 Fri, 27 Feb 2004 15:27:57 GMT   
 How to use echo in an expect-script
You could try specifying the command version of echo /usr/bin/echo or /bin/echo
(depending in your OS)

your assuming that the shell builtin would work - which is unlikely
give that a try - remember you need to specify that path to the command as well.



 Fri, 27 Feb 2004 18:02:39 GMT   
 How to use echo in an expect-script
In article <3B9C8FBF.E228F...@lucent.com>,
Kev Miles  <kdmi...@lucent.com> wrote:

Mr. Miles is right that /bin/echo and such will take
you farther.  I think we can solve your problems 2.
and 3., also--they might be just matters of quoting--
but let's take one step at a time.

I want to be sure I understand your description; is
your /dev/ttyS0 target on the machine where you are
running Expect, or the one to which you intend to
connect?  If it's either of those cases, I doubt that
  spawn echo ... > /dev/ttyS0
will be what you want.
--

Cameron Laird <cla...@NeoSoft.com>
Business:  http://www.Phaseit.net
Personal:  http://starbase.neosoft.com/~claird/home.html



 Fri, 27 Feb 2004 20:23:48 GMT   
 How to use echo in an expect-script

Well it was a good hint - but I wonder why does telnet and cat works
without full pathes? Nevertheless, the problem remains:(

I wanna explain my script and explain what it sould do.

the script:
=======================================
#!/usr/bin/expect -f
global CAT
spawn cat /dev/ttyS0
set CAT $spawn_id
#some 'expect' stuff
spawn " /bin/echo "M\r" > /dev/ttyS0 "
interact #only for testing
======================================

The script start a cat on the serial interface in order to a have a
"display" of
 the other pc. The it sould expect some stuff and then send the echo.

Here are my attemps and the errors. I always change the 6. line:

1. spawn " /bin/echo "M\r" > /dev/ttyS0 "
  --> extra characters after close-quote
      while compiling
      "spawn " /bin/echo "M\r" > /dev/ttyS0 "..."
     (file "./script.exp" line 6)

2. spawn "/bin/echo "M\r" > /dev/ttyS0"
  --> extra characters after close-quote
      while compiling
      "spawn "/bin/echo "M\r" > /dev/ttyS0"..."
      (file "./script.exp" line 6)

3. spawn [ /bin/echo "M\r" > /dev/ttyS0 ]
  --> spawn cat /dev/ttyS0
      invalid command name "/bin/echo"
      while executing
      "/bin/echo "M\r" > /dev/ttyS0 "
     (file "./script.exp" line 6)

4. spawn [ "/bin/echo "M\r" > /dev/ttyS0" ]
  --> extra characters after close-quote
      while compiling
      ""/bin/echo "M\r" > /dev/ttyS0" ..."
      while compiling
      "spawn [ "/bin/echo "M\r" > /dev/ttyS0" ]..."
     (file "./script.exp" line 6)

5. spawn { "/bin/echo "M\r" > /dev/ttyS0" }
  --> spawn cat /dev/ttyS0
      spawn  "/bin/echo "M\r" > /dev/ttyS0"  
      couldn't execute " "/bin/echo "M\r" > /dev/ttyS0" ": no such
file or       directory
      while executing
      "spawn { "/bin/echo "M\r" > /dev/ttyS0" }"
      (file "./script.exp" line 6)

Here are some information:

$ ls -l /bin/echo
-rwxr-xr-x   1 root     root         7972 Nov  8  1999 /bin/echo

$ expect -v      
expect version 5.30.1

Ita est || Yeah, it is;)

Well, it's a little bit unnormal nowadays: There is a serial
connection between the two computers. So I can send command to it via
$ echo -en "lets_do_sth\r"> /dev/tty

I hope you can help me. I'm getting crazy her;(

Thanks for your help (also in advance;)

Regards, Martin

ps.: you can set a f'up i f you want. It's not (yet?) possible with
google.



 Sat, 28 Feb 2004 16:09:52 GMT   
 How to use echo in an expect-script
In article <d8cc4b43.0109110009.429b5...@posting.google.com>,
                        .
                        .
                        .
                        .
                        .
                        .
Most commands work as you would want.  echo is
exceptional and confusing, because it's built-in
to the shell.  A design decision was made in
Expect that shell built-ins must be specified as
fully-qualified executables (in effect).
--

Cameron Laird <cla...@NeoSoft.com>
Business:  http://www.Phaseit.net
Personal:  http://starbase.neosoft.com/~claird/home.html



 Sat, 28 Feb 2004 20:05:34 GMT   
 How to use echo in an expect-script
In article <d8cc4b43.0109110009.429b5...@posting.google.com>,
                        .
                        .
                        .
                        .
                        .
                        .
A.  Brian K Ivins posted a brief follow-up that
    was absolutely on-target.  I think you'll be
    far better off pursuing his recommendation.
B.  You're having a LOT of trouble with quoting
    concepts in these attempts.  To understand
    Tcl syntax better, you might do well to start
    with <URL: http://mini.net/tcl/1726 >.
--

Cameron Laird <cla...@NeoSoft.com>
Business:  http://www.Phaseit.net
Personal:  http://starbase.neosoft.com/~claird/home.html



 Sat, 28 Feb 2004 20:55:27 GMT   
 How to use echo in an expect-script
In article <FA3662969DD525BB.75217E2750004B2B.AA852BFFBD450...@lp.airnews.net>,
...

Really?

I just tried:

% expect
expect1.1> spawn echo this and that
spawn echo this and that
23922
expect1.2> expect
this and that
expect1.3>
%

I assume it is running the /bin/echo program.



 Tue, 02 Mar 2004 12:56:11 GMT   
 
   [ 7 post ] 

Similar Threads

1. MINICOM and scripts using RUNSCRIPT, EXPECT and /bin/sh for automation

2. PPP over telnet using expect script

3. wanted: expect script for ppp client using dynamic address

4. Problem using Xterm in Expect script

5. Problem using Xterm in Expect script

6. Help using expect script

7. inetd pty shell echo & expect

8. expect script help - example script included

9. echoing variables in scripts


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software