Page 1 of 1

How to use commands like xterm, spawn, expect, etc.

Posted: Fri Sep 14, 2012 7:27 am
by humid
Hi all, I'm new to this openwrt world and I'm trying to improve my learnings about it a little further, I hope you can help me.

The matter is this:

I have the main script which calls the second script with the following command:

Code: Select all

for ROUTER in {1..10}
do
xterm -iconic -e $path/runscript.sh $ROUTER &
done
and the runscript.sh code is:

Code: Select all

#!/bin/bash
#!/usr/bin/expect -f

set arg1 [lindex $argv 0]
spawn ssh root@192.168.$arg1.1 ; 
expect password ; 
send "12345\n" ; 
expect '~#' ; 
send "./script3.sh\n" ; 
interact
And the result is always:

Code: Select all

- bash: xterm: command not found
- bash: spaw: command not found
- bash: expect: command not found
- bash: send: command not found
- bash: interact: command not found
I've already installed the bash package along with other libs but the problem is always the same, do you have any clue?

Thanks

Re: How to use commands like xterm, spawn, expect, etc.

Posted: Fri Sep 14, 2012 9:33 pm
by Eric
The small size of the routers on which OpenWRT runs require that it uses smaller, more lightweight command line utilities that what are typically found on larger linux distributions. bash, xterm and expect are not installed by default. The default shell used by OpenWRT is called ash and has a lot of bash-like syntax, but it isn't bash.

You're going to need to optimize your script(s) for the utilities OpenWRT does use. Most of these are provided by the Busybox suite of utilities. Take a look at the Busybox documentation for more details on what is available.