Find the answer to your Linux question:
Results 1 to 2 of 2
Hi All, I am basically a database person. I need to create dependency between two shell scripts. This is basically related to data loading. For example one of my application ...
  1. #1
    Just Joined!
    Join Date
    Mar 2009
    Posts
    1

    Creating dependency between two scripts

    Hi All,

    I am basically a database person. I need to create dependency between two shell scripts. This is basically related to data loading. For example one of my application is running and it places a file by the name account.txt under

    /home/user1

    dir. My application places a new at this location every 20 seconds. So once I have a file under this dir, I need to run script1 that moves this account.txt file from /home/user1 directory to say /home/loaded dir and then I need to run another shell script script2 which will have database stuff related to loading this file to the database. once it's done, my application will again place a file at the location /home/user1 by the same name account.txt and again I need to run script2 to load it to database.

    This is a real time stuff and these two scripts ( script1 and script2 needs to be run in a specified fashion first script1 and then script2).

    Now in case my database stops running for some reason, I don't want to loose data and want the script1 to continue running and moving file from /home/user1 dir to /home/loaded dir so that once my Database is up, I can go ahead and load those files.

    Could you people, please guide me how to achieve this functionality through an example.

    I shall be thankful to you.

    Regards,
    Devshree

  2. #2
    Linux Enthusiast meton_magis's Avatar
    Join Date
    Oct 2006
    Location
    arizona
    Posts
    665
    you could have a script that is persitently running (use a loop in your script) that has an if condition of something like "if file exists, run database stuff, else, sleep for 10 seconds, and continue loop" or whatever (I believe the syntax is something like

    if [ -f /home/user1/account.txt]
    then
    run stuff here
    else
    sleep 10
    continue
    fi

    but i'm not 100% sure. as for the other, you could do the reverse, if the file exists, sleep for 10 seconds, else run the commands to make the account.txt file.

    That is how I would do it, maybe not optimal, but it would work for how I understand your problem.
    New to the internet, technical forums, or the hacker / open source community??
    Read this to learn good posting habits http://www.catb.org/~esr/faqs/smart-questions.html

    RHCE for RHEL version 5
    RHCT for RHEL version 4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...