I want to run this program as root. It activates a virtual environment and runs a python program in that virtual environment.The program looks like this $cat myfile.shsource /pathto/venv/bin/activatepython /pathto/rsseater.pyIf I just run it as root I get$ sudo ./myfile.sh ./myfile.sh: 2: ./myfile.sh: source: not foundI found this but if I try to add sudo -s to the top of the file it seems to change the prompt to a # -- but the python does not run as expected. I'm not sure what the program is doing when I have sudo -s at the top of the file like that.  How can I get this program to run as root?
sudo source: command not found
cron
You generally want to add a call to an interpreter at the top of your scripts, like so:$cat myfile.sh#!/bin/bashsource /pathto/venv/bin/activatepython /pathto/rsseater.pyThis may seem very similar to what you have but is it in fact very different. In your scenario you're attempting to run the commands within the shell that get's invoked when you run sudo. With the example above, you're getting a separate Bash shell which will have the various commands after the #!/bin/bash line invoked within it. #!/bin/bash results in a new Bash shell getting forked.Interpreters and shebangThe nomenclature of #! is called a shebang. You can read more about it through the various Q&A on this site and also on Wikipedia. But suffice to say, it tells the system that when a given file is executed (aka. run) to load a program from disk first (an interpreter), which then is tasked with the job of parsing the contents of the file you just executed. NOTE: Essentially everything after the shebang line.InterpretersAn interpreter is any program that can process commands one at a time from a file. In this case we're using the Bash shell as the interpreter. But there are other shells that you could use here too, such as C shell or Korne shell among others.You can also use higher level interpreters such as Perl, Ruby, or Python too in this same manner.Why the error using 'sudo -s'If you take a look at the man page for sudo it has this to say about -s: -s [command]            The -s (shell) option runs the shell specified by the SHELL             environment variable if it is set or the shell as specified in             the password database.  If a command is specified, it is passed            to the shell for execution via the shell's -c option.  If no             command is specified, an interactive shell is executed.So when you run this command:$ sudo -s ./myfile.shThe following happens:$ /bin/shsh-4.2$ source somesource.bash sh: source: somesource.bash: file not foundThe shell, /bin/sh does not support the command source.