0

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 cdpart would be executed.
Is there a simple way to pass the arguments as seperate arguments but at once?

user2546460
  • 1,223
  • 2
  • 8
  • 8

1 Answers1

1

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.

Community
  • 1
  • 1
user2546460
  • 1,223
  • 2
  • 8
  • 8