2

I’m trying to get this ~/Desktop/Tor/tor-browser_en-US/ && ./start-tor-browser to run as a .sh. I've tried over and over again to get it to work, what am I doing wrong?

#!/bin/bash 
chmod +x file.command ~/Desktop/Tor/tor-browser_en-US/ && ./start-tor-browser

It has execute permissions and is saved as an .sh.

  • Have you added `#!/bin/sh` as the very first line of your script? – Terrance Apr 22 '15 at 03:19
  • yes, but its `#!bin/bash` and it has a line between it and my code. – Shonn Alves Apr 22 '15 at 03:21
  • `#!/bin/bash` tells the script to run in the bash shell and not the sh shell. Change it to `#!/bin/sh` – Terrance Apr 22 '15 at 03:21
  • I changed bash to sh, didnt work. – Shonn Alves Apr 22 '15 at 03:23
  • So that would look like `sudo #!/bin/sh chmod +x file.command ~/Desktop/Tor/tor-browser_en-US/ && ./start-tor-browser` ? – Shonn Alves Apr 22 '15 at 03:24
  • Where is the `./start-tor-browser`? Is that located in the `~/Desktop/Tor/tor-browser_en-US/` folder? if so, your script should be `#!/bin/sh` as the first line. And `cd ~/Desktop/Tor/tor-browser_en-US/ && ./start-tor-browser` as the second line. – Terrance Apr 22 '15 at 03:26
  • No, you need to run `chmod +x ` as a separate command after you save the file – mchid Apr 22 '15 at 03:26
  • so i need to save the file with `#!/bin/sh chmod +x file.command ~/Desktop/Tor/tor-browser_en-US/ && ./start-tor-browser` and create an new .sh that says `chmod +x `? – Shonn Alves Apr 22 '15 at 03:29
  • `chmod +x` sets the executable bit for a file. `./start-tor-browser` is the command to start whatever that is. `chmod +x` is not needed in a script, as it does not need to set the bit every single time you run it. I am assuming that `~/Desktop/Tor/tor-browser_en-US/` is the folder on the desktop where `start-tor-browser` exists? – Terrance Apr 22 '15 at 03:32
  • yes, that were it is. And yes, `#!/bin/sh` as the first line and `cd ~/Desktop/Tor/tor-browser_en-US/ && ./start-tor-browser` as the second line. – Shonn Alves Apr 22 '15 at 03:35
  • I'm going to write an answer with a way to create a script that will work for this. – Terrance Apr 22 '15 at 03:36
  • No, i dont think so. It works in the console without root, it does need cd though. – Shonn Alves Apr 22 '15 at 03:43

1 Answers1

0

Open a terminal and execute the following commands:

sudo nano /bin/start-tor

and copy/paste this into the file:

#!/bin/bash
~/Desktop/Tor/tor-browser_en-US/Browser/start-tor-browser

Press CTRL + o to save the file and press CTRL + x to exit and then execute the following commands in an open terminal:

sudo chmod +x /bin/start-tor

To run the script, open a terminal and run:

start-tor &

This file is already chmod +x when downloaded.so there is no need to do all that.

mchid
  • 42,315
  • 7
  • 94
  • 147
  • @ShonnAlves then erase all that stuff re-download it and extract the file again – mchid Apr 22 '15 at 03:42
  • @ShonnAlves I edited the answer to be more thorough and I just tested this and it works just fine for me – mchid Apr 22 '15 at 03:47
  • @ShonnAlves in the future, you would've just needed to run `chmod +x ~/Desktop/Tor/tor-browser_en-US/Browser/start-tor-browser` if you want to make that file executable. I think they confused you with the whole file.command thing it probably should have read `` or something like that instead so you would have known to substitute something else there. ohwhell glad to help! – mchid Apr 22 '15 at 03:54
  • For future reference, will "cd"work in nano mode? Forgive me for my apparent ignorance. – Shonn Alves Apr 22 '15 at 03:55
  • @ShonnAlves you could've used `cd /bin` first, and then `sudo nano start-tor` instead – mchid Apr 22 '15 at 04:00
  • @ShonnAlves sorry I edited that last response – mchid Apr 22 '15 at 04:01
  • @ShonnAlves or, if you just wanted to run the tor browser from the terminal without nano you could run `cd ~/Desktop/Tor/tor-browser_en-US` and then `./start-tor-browser` – mchid Apr 22 '15 at 04:05