When I try to run "yum -y update" from a Bash script it doesn't work.
Here is what the script looks like.
#!/usr/bin/
echo "--> Updating CentOS System"
yum -y update
I run the script with this command.
bash script.sh
I get the following output.
Loaded plugins: fastestmirror, refresh-packagekit, security
. Please use /usr/bin/yum --help.
CentOS 6 FINAL
Installed via text prompts.
I login as root from the text prompt then startx to get into the gui desktop.
But when I run the same command directly in the terminal it works?
I've googled around but not sure if I'm googling the correct terms.
Thanks for your help.
Best Answer
Not sure why your script does not work, but my version worked fine. (I suspect it might be the first line):
Remember to chmod 755 the file, and you can just run it with the file name, no need to prepend it with "bash".
I do note that when I tried to reproduce your problem I couldn't (even though your first line is incorrect the script still worked for me). I wonder if there might have been a hidden typo in the key shell line ? Maybe try deleting it and re-adding it.