Hello

I want to make two shell scripts but they shell scripts isnt exactly my language :P

The following is all pseudocode
The first script will run every say 5 minutes:

if /tmp/media/sda1 exists or /tmp/media/sda2 exists or /tmp/media/sda3 exists or /tmp/media/sda4 exists
then do
        variable storage=what ever above first returns true (lets say /tmp/media/sda3)
        //storage=/tmp/media/sda3
        if storage+"/"+.runmescript exist
        then do
        ./runmescript
        end if
end if

thats the first one.

Now we have on the harddrive a file called "someconf" at /etc/ also at /tmp/media/sda3 we have a file called "update". someconf has a line that says "dot=99" while update has a line that says "dot=11"

".runmescript" would be.

load /etc/someconf
     search for "dot=99" in /etc/someconf
          load /tmp/media/sda3/update
             search for "dot=11"
             replace line from update in somesonf
save

how can i do this? thank you!

Well I think another question to ask what shell you were hoping to code this in. It does make a slight difference. But for the hell of it i'll assume your using the bash shell.

Not 100% sure this will work, I no longer have a unix env to test this in.
Script 1:

  function ur_script($file)
    {
    if [ $file = '/tmp/media/sda1' ] || [ $file = '/tmp/media/sda2' ] || [$file = '/tmp/media/sda3' ] || [ $file = '/tmp/media/sda4']
    then 
         $storage = $file; 
         if [ -f $storage+'/'+'.runme' ] 
            then 
                 ./$storage+'/'+'.runme'
         fi 
    else
        echo "Error: File Not Found"; 
    fi 
    }

Can't help you with the second on though sorry.

Edited 4 Years Ago by soapyillusion

thanks anyways soapyillusion :) but a function is not ideal for this

Edited 4 Years Ago by riahc3

This article has been dead for over six months. Start a new discussion instead.