Hopefully a simple question on an expect/unix problem I have.
I spawn a shell (csh) and then send a very long command to it. What I
see when I have the expect debug on is part of the command is echoed but
the rest is made up of the annoying beep signal (\u0007).
I have been unable to find if there is a max char limit on the command
line (Doubtful as this works ok if I type it in manually on the command
line.) or is there a limit with expect?
See output below
spawn /usr/bin/csh
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {19682}
send: sending "bs -sim -testrt -testrt_include 'coli_validator.c
filepath_validator.caccSrvCtrl.c froDataHandler.c intSecLevel.c
secMode.c secMode_getopt_r.csecModeCmd.c secModeUtil.c idl_validator.c
ipom_loghandler.c operation_validator.c secroot.c session.c user.c
user_authentication_L1.c user_validator.c vls_fro.c vls_proc.c
vls_utils.c'\r" to { exp4 }
expect: does "" (spawn_id exp4) match regular expression "([^\n]*)\n"? no
"Argv"? no
bs -sim -testrt -testrt_include 'coli_validator.c
filepath_validator.caccSrvCtrl.c froDataHandler.c intSecLevel.c
secMode.c secMode_getopt_r.csecModeCmd.c secModeUtil.c idl_validator.c
ipom_loghandler.c operation_validator.c secroot.c session.c user.c user_
expect: does "bs -sim -testrt -testrt_include 'coli_validator.c
filepath_validator.caccSrvCtrl.c froDataHandler.c intSecLevel.c
secMode.c secMode_getopt_r.csecModeCmd.c secModeUtil.c idl_validator.c
ipom_loghandler.c operation_validator.c secroot.c session.c user.c
user_\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007"
(spawn_id exp4) match regular expression "([^\n]*)\n"? no
"Argv"? no
/vobs/cello/civ/simcello_example/bp_lm->
expect: does "bs -sim -testrt -testrt_include 'coli_validator.c
filepath_validator.caccSrvCtrl.c froDataHandler.c intSecLevel.c
secMode.c secMode_getopt_r.csecModeCmd.c secModeUtil.c idl_validator.c
ipom_loghandler.c operation_validator.c secroot.c session.c user.c
user_\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007/vobs/cello/civ/simcello_example/bp_lm->
" (spawn_id exp4) match regular expression "([^\n]*)\n"? no
"Argv"? no
expect: timed out
blah
You did not mention which Unix system you're on. Some systems pose a
limit on the argv/environment size when calling exec, but this is
rather something around 8kB. (IRIX has something like that tuneable).
On Linux, I can provoke that by eg:
% ls * */* */*/*
/bin/ls: Argument list too long.
On IRIX, we had an issue like that when 'make' wanted to pass several
hundred file names to 'ar'.
So yes, there is a limit on the length of the command line, and no,
with the example you've shown you should not have exceeded that.
| send: sending "bs -sim -testrt -testrt_include 'coli_validator.c
| filepath_validator.caccSrvCtrl.c froDataHandler.c intSecLevel.c
| secMode.c secMode_getopt_r.csecModeCmd.c secModeUtil.c idl_validator.c
| ipom_loghandler.c operation_validator.c secroot.c session.c user.c
| user_authentication_L1.c user_validator.c vls_fro.c vls_proc.c
| vls_utils.c'\r" to { exp4 }
This is not 'long' ;-) Well, its > 256 characters, but it would
surprise me if there was such a low limit somewhere in there...
Did you try to use /bin/sh instead of csh? Usually sh is the better
choice to execute non-interactive commands.
R'
I thought it was bigger than that (environments can easily get up to
near that size). Indeed, a little investigation indicates that the limit
on at least one convenient Linux box is 128kB.
> On IRIX, we had an issue like that when 'make' wanted to pass several
> hundred file names to 'ar'.
This sort of thing usually comes up when dealing with the output of
'find', and is why the 'xargs' program was created. :-)
> This is not 'long' ;-) Well, its > 256 characters, but it would
> surprise me if there was such a low limit somewhere in there...
The limit on Windows (especially on non-NT systems) is *much* smaller.
On the other hand, that platform generally expands wildcards in the
program after it has started, so the limit bites a little less in normal
use.
Donal.
You may as well have hit a limit of the "csh" or even of the line discipline
(the tty device). Just a hint...
Cheers,
--
Heiner Marxen http://www.drb.insel.de/~heiner/
Try calling "cat" instead of "csh":
If with "cat" you also see the \u0007's, then it's the tty's fault,
otherwise it is csh's fault. Try sh or ksh or bash or zsh instead.
Anyway: <http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/>
Thanks for the suggestions. Someone that sits in my building showed me
the solution!
set send_slow {100 1}
spawn /usr/bin/csh
set timeout 20
exp_send "stty raw\r"
expect "stty raw\r"
exp_send -s "bs -sim -testrt -testrt_include 'coli_validator.c
filepath_validator.caccSrvCtrl.c froDataHandler.c intSecLevel.c
secMode.c secMode_getopt_r.csecModeCmd.c secModeUtil.c idl_validator.c
ipom_loghandler.c operation_validator.c secroot.c session.c user.c
user_authentication_L1.c user_validator.c vls_fro.c vls_proc.c
vls_utils.c'\n"
It appears to be a timing problem and there are some hints in Don Libes
book p274 about 'cooked mode'
/James