0

My script is as follows:

#!/bin/sh

rm -rfv /home/user/Documents/Exercise/*

cp -rfv /home/user/Documents/ExerciseShare/ExerciseFiles/Word/Advanced/ /home/tp3/Documents/Exercise/

If i was to run these commands individually via Terminal they run ok. I have put them in a script (as above) and when I attempt to tun the script the Terminal windows flashes for about a second and nothing happens.

My attempts at solutions:

  1. Adding wait to the end of the script - no luck
  2. Right Click Script > Properties > Permissions > Execute - set
  3. Attempted to Run and Run in Terminal - no luck

I am using Ubuntu 12.10 64-bit

Mitchell
  • 153

2 Answers2

0

After many more hours of tinkering I have found an unlikely answer.

I created a new blank document and added only the two lines I wanted (without the heading of #!/bin/sh) :

rm -rfv /home/user/Documents/Exercise/*
cp -rfv /home/user/Documents/ExerciseShare/ExerciseFiles/Word/Advanced/ /home/tp3/Documents/Exercise/

I then saved the document, right-click > properties > permissions > execute as program

Bingo!

Thanks to all that helped!

Mitchell
  • 153
0

According to your comment, you had introduced an extra carriage return (\r) at the end of your shebang line

/bin/sh^M: bad interpreter

If you open your original file in vim, you'd see the ^M character; you could just remove it. Or you could open it in a hex editor such as hexedit, where you'd see an extra 0D.

Linux newlines are single newline characters (\n, 0x0A), as opposed to Windows newlines which still hark back to the days of typewriters (\r\n, 0x0D 0x0A).