How do I make a shell script based on a command line and have it run every day on a mac?

I hope someone can help me as this is my first attempt to make a shell script.

I have set up an Adobe Software Update server. Using the Terminal.app I can manually send a command to the Adobe Update Software Setup Tool (AUSST) to check if there are new software updates at Adobe, which are then downloaded and available to our users.

The command line is:
sudo /Users/macpostur/Desktop/AUSST/AdobeUpdateServerSetupTool  --root=/Library/WebServer/Documents/Adobe --incremental

It asks for the password and then runs.

I would like to make this command run once every day at 23:00, preferably as a shell script run by launchd. I bought Lingon and I just downloaded LaunchControl but I am getting nowhere. Errors I get when this is run have error codes 126, which seem to say that permissions are not ok.

The thing is I don't know what should be inside the .sh file.

Questions:

1. What text from the command should be inside the .sh text file? Complete.
2. What permissions should I set for the .sh file? chmod + what?
3. Where should I keep the .sh file?
4. What settings should I set in Lingon or LaunchControl? Or more specifically: How do I run this every day?
LVL 22
Sigurdur ArmannssonDesigner Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

strungCommented:
This article on Cron Scripts should help on the issue of running the script on a daily basis:

http://www.maclife.com/article/columns/terminal_101_creating_cron_jobs
0
strungCommented:
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Christopher Jay WolffWiggle My Legs, OwnerCommented:
New to this also.  Here is a pretty good guide for scripting

http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.html

which yields the following...

----------------------------------------------

1.  the command should be just like you type it when it works.

-------------------------------------------

2.

It sounds like you need to set the execute permissions for your .sh file to be able to run it.  The below is under "Creating and Running a Script"

2.1.3. Executing the script

The script should have execute permissions for the correct owners in order to be runnable. When setting permissions, check that you really obtained the permissions that you want. When this is done, the script can run like any other command:


willy:~/scripts> chmod u+x script1.sh

willy:~/scripts> ls -l script1.sh
-rwxrw-r--    1 willy      willy            456 Dec 24 17:11 script1.sh

 



--------------------------------------------
3.
Write this script for yourself as well. It might be a good idea to create a directory ~/scripts to hold your scripts. Add the directory to the contents of the PATH variable:

export PATH="$PATH:~/scripts"

If you are just getting started with Bash, use a text editor that uses different colours for different shell constructs. Syntax highlighting is supported by vim, gvim, (x)emacs, kwrite and many other editors; check the documentation of your favorite editor.

----------------------------------------------

4.

Why not just use launchd?  Make sure the launchdaemon is started.  As discussed here.

http://hints.macworld.com/article.php?story=2012073000433650

and here...

http://alvinalexander.com/mac-os-x/launchd-examples-launchd-plist-file-examples-mac

and here...

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man5/launchd.plist.5.html

and some examples

http://launchd.info/
0
Christopher Jay WolffWiggle My Legs, OwnerCommented:
launchd is backwards compatible with Cron.
0
Sigurdur ArmannssonDesigner Author Commented:
Thanks guys. Plenty to check out. Let me read and try and I'll be back.
0
serialbandCommented:
Don't create a script with sudo in it.  Create a cron that's run as root and you won't have to enter a password for sudo.

If you're using launchd, you shouldn't have to use sudo either.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sigurdur ArmannssonDesigner Author Commented:
I am distributing the points between you three for the information.
I have tried some of what I have read in the links and also some based on the advice but I am not there yet. The links you gave are helpful and hopefully they lead to a solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.