Does Folder2's name ever change, or is it always the same?
As a start, you could do something like this:
Code:
#!/bin/bash
sim2Dir=$1
if [ -d "../$sim2Dir" ]; then
if [ -e "code.bin" ]; then
cp "code.bin" "../$sim2Dir" && eval "../$sim2Dir/code.bin"
else
printf "The file 'code.bin' does not yet exist!"
exit 1
fi
else
printf "There is no directory called: %s\n" $sim2Dir
fi
The script will check for "folder2" and if it exists, it will cp 'code.bin' to that folder and execute it (I used eval because I don't know what kind of script it is...you might want to change how it's executed there). If folder2 does not exists, then you get an error and the program exits. You could change that error section to make it create folder2 and so on.
To use the script, you can make it executable:
And then run it like this:
Code:
./cp_run.sh folder2
Folder2 should be the actual name of the folder where you want to copy and run the 'code.bin' script.
Bookmarks