Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: creating Linux or Unix Automated Script help  (Read 5006 times)

0 Members and 1 Guest are viewing this topic.

DECronk

  • Guest
creating Linux or Unix Automated Script help
« on: January 28, 2008, 04:22:08 PM »
Hi There-

I am just learning how to do UNIX/Linux work and I have been charged with trying to write a script to automate a couple of processes.

The series of commands is as such.

script 1:

open shell
cd /w/config
rm mgd_stage   
ln -s mgd_stage_normal mgd_stage   
 
"perform TPS reset"

---------------------------
script 2:
 
open shell
cd /w/config
rm mgd_stage   
ln -s mgd_stage_horse mgd_stage   

perform a "TPS reset"
 

I know how to do this normally, but would like to be able to just type in a command at the prompt, ie:   stage_normal   or stage_horse so that the user doens't have to go through all of that work each time...

Anyone out there willing to walk me through this process would be GREATLY appreciated.

Kind Regards,

DECronk

Soviet_Genius

  • Guest
Re: creating Linux or Unix Automated Script help
« Reply #1 on: January 29, 2008, 02:38:04 PM »
Just put all that into a text editor and save it as a .sh file. This is the equivalent of batch files on Windows.

Rob Pomeroy



    Prodigy

  • Systems Architect
  • Thanked: 124
    • Me
  • Experience: Expert
  • OS: Other
Only able to visit the forums sporadically, sorry.

Geek & Dummy - honest news, reviews and howtos

phoenix910



    Hopeful

    Thanked: 2
    Re: creating Linux or Unix Automated Script help
    « Reply #3 on: February 17, 2008, 05:00:46 AM »
    script 1:

    #!/bin/bash
    cd /w/config
    rm -r mgd_stage
    ln -s mgd_stage_normal mgd_stage
    #tps_reset_command here (I am unsure of this command)

    ---------------------------
    script 2:

    #!/bin/bash
    cd /w/config
    rm -r mgd_stage
    ln -s mgd_stage_horse mgd_stage
    #tps_reset_command here (I am unsure of this command)


    That should do what you want it to. Basically, you put one command on each line, or simply all on one line:
    #!/bin/bash
    cd /w/config && rm -r mgd_stage && ln -s mgd_stage_horse mgd_stage && tps_reset_command

    Hope that helps


    -Stephen