How to call a shell script and pass argument from another shell script

后端 未结 1 1194
半阙折子戏
半阙折子戏 2021-02-07 11:39

I\'m calling a shell script from another shell script and the called script requires some input (command line) parameters.
I\'m have below mentioned code, but thats not work

1条回答
  •  孤街浪徒
    2021-02-07 11:43

    By sourcing the second script with . /home/admin/script2.sh, you're effectively including it in the first script, so you get the command line arguments to the original script in $@. If you really want to call the other script with arguments, then do

    /home/admin/script2.sh "$ARG1" "$ARG2" "$ARG3"
    

    (make sure it's executable).

    0 讨论(0)
提交回复
热议问题