4

I am trying to spawn scp command to copy one file from one server to another server. So, I am passing 8 arguments to an expect script as follows

expect my_x_script.exp file_src file_dest s_user s_pass s_host d_user d_pass d_host

Is it valid to pass these many arguments to an expect script?

1
  • it does successful copy from one remote machine to another remote machine Commented Oct 13, 2016 at 11:13

1 Answer 1

3

Yes there's no problem with that many arguments. Depending on your expect version, you extract the values with one of these:

lassign $::argv \
    src_file  src_user  src_pass  src_host \
    dest_file dest_user dest_pass dest_host
# or
foreach {src_file src_user src_pass src_host dest_file dest_user dest_pass dest_host} $::argv {break}

At some point, the user interface gets hard to manage though. You might want to look into using command line options to help keep things straight. Check out the cmdline package from tcllib. Then you can do:

expect my_x_script.exp \
    -src_file file_src \
    -src_user s_user \
    -src_pass s_pass \
    -src_host s_host \
    -dest_file file_dest \
    -dest_user d_user \
    -dest_pass d_pass \
    -dest_host d_host
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .