-   Linux - Newbie (
-   -   Application Rotation (

lonesoac0 04-17-2012 06:49 PM

Application Rotation
2 Attachment(s)
Hello all,

I created a bourne shell script that lets me launch feh and firefox without first having a X session. I am running this script with the help of the crontab program. The sytax that I use for launching my script is:

*/8 * * * * $HOME/feh_and_firefox &
The issue that I am having is that the script feh_and_firefox, occasionally does not write to my .number file. As a result my .number file does not have a value at all. I do not know what could be causing this problem.

Please advise. :)

chrism01 04-17-2012 07:19 PM

I'd start by adding a default clause at the bottom so that if no previous numbers are matched, it writes some useful info to .number.

Also, add

set -xv
just after the #!/bin/sh line and redirect/capture all output in a log file.

Any reason for using sh instead of bash?

lonesoac0 04-17-2012 07:37 PM

I did have something at the bottom of the script to do what you suggested but I thought that I was doing something wrong. I had something like:

if [ "$blah" -eq "" ]
  echo "1" > $HOME/.number

The reason that I removed that simple clause was that I thought that I was doing something wrong with my original scripting. In theory, I should not have to write the additional code since my original code goes into a loop.

As for the

set -xv
Just to be sure, you want me to add it like:
line 1: #!/bin/sh
line 2: set -xv

Finally, I use bourne shell for the portability of the scripts that run on it. It is true that Bash is the defacto shell, but for my previous stated reason and personal preference. If you can think of a better Bash script then I am alllll ears! ;) Thank you for your response.

chrism01 04-18-2012 12:52 AM

Re set cmd: yep, just like that

Re default; don't use an if, just record what the param was and the current value in .number; in fact the entire content of .number, and put it in a separate logfile.
(along with the set -xv output).

Can I also recommend [[ ]]

All times are GMT -5. The time now is 01:01 PM.