Reputation: 1443
I have an expect
script that executes the commands given as arguments like this:
!/usr/bin/expect
spawn telnet ip
for {set i 0} {$i < $argc} {incr i 1} {
set cmd [lindex $argv $i]
send "$cmd\n"
}
And I can call it with whatever commands I want to execute on the remote device e.g. my_expect_script "cd /home" "ls" "mkdir mydir"
. I would like to have something executed before this script by default. My idea was to write another script like this:
#!/bin/bash
do-something
my_expect_script "$*"
Now if I do so the my_expect_script
seems to get only one argument. In my example only the cd
part would be executed.
Is there a simple way to pass the arguments as seperate arguments but at once?
Upvotes: 0
Views: 390
Reputation: 1443
Just found the solution here. I have to adapt the second script as follows:
#!/bin/bash
do-something
my_expect_script "$@"
I always thought $*
and $@
do exactly the same.
Upvotes: 1