linux - Bash script failing to execute bash script -
i'm trying run script installs files in directory user specifies. once user specifies directory, i'd transfer main file directory can perform more tasks there before deleting once complete.
#prompt directory in build project read -p "drag , drop directory in you'd build project: " echo "reply $reply" cp ./myscript.sh $reply /bin/bash $reply/myscript.sh
i've got script execute file question. tried doing source $reply/myscript.sh
sh $reply/myscript.sh
. error /path/to/file/ directory
it must doesn't known i'm trying run myscript.sh, don't understand how i've given directory.
a cause drag-and-drop putting whitespace after directory name.
thus:
/bin/bash $reply/myscript.sh
would running
/bin/bash /path/to/directory /myscript.sh
a simple fix, if that's standard space, be:
/bin/bash "${reply% }/myscript.sh"
Comments
Post a Comment