Results 1 to 4 of 4

Thread: shell script to control a shell script?

  1. #1
    Join Date
    Nov 2019

    shell script to control a shell script?

    I'm still new with linux but, I have a server with ubuntu 18.04.

    I've installed and gotten running a rust game server using LGSM
    I control the server with commands like: ./rustserver restart, ./rustserver wipe.

    During a wipe and/or an update i have to do somethings manually that i'd like to automate.
    But I cant get my script to control the other script, I'd be grateful of some pointers or even a good link to read up on this type of thing.

    heres my script:
    echo "Wipe & update Started Please Wait"
    ./rustserver stop
    sleep 30s
    rm /home/rust1/serverfiles/oxide/data/Kits_Data.json /home/rust1/serverfiles/oxide/data/PlayerRanks.json /home/rust1/serverfiles/oxide/data/ServerRewards/player_data.json
    echo "Plugin Data Deleted Successfully"
    Sleep 2s
    echo "Full Wipe Starting"
    ./rustserver wipeall
    echo "Full Wipe Process Completed"
    sleep 10s
    echo "Updating Rust Now"
    ./rustserver update
    sleep 120s
    echo "Updating Oxide"
    ./rustserver mods-update
    sleep 120s
    Echo "Updates Completed Starting The Server!"
    the other issue is I'm putting time delays in because i dont know how to get my script to interact with the other one
    ./rustserver stop
    this will start a 'softstop' which can take upto 30 seconds, then says something like 'server stopped' but my scripted doesnt know that so i have to just make it wait x seconds?

    Thanks in advance for any help

    this is the script I'm trying to control from LGSM:
    Last edited by youmustnot; 6 Days Ago at 03:23 PM.

  2. #2
    Join Date
    Oct 2006

    Re: shell script to control a shell script?

    Thread moved to the "Server Platforms" forum for a better fit.

  3. #3
    Join Date
    Nov 2008
    Metro Boston
    Kubuntu Development Release

    Re: shell script to control a shell script?

    ./rustserver will only work if you're in the directory where rustserver is stored. Use a full path like /usr/local/bin/rustserver or whatever.

    Also, I'm assuming you've marked your script executable, right?
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  4. #4
    Join Date
    Mar 2010
    Ubuntu Mate 16.04 Xenial Xerus

    Re: shell script to control a shell script?

    The output from 1 command can be read by a shell script.
    the return code/exit status from the prior program can be checked by reading $#. In Unix, a zero (0) exit means everything is fine. A non-zero exit means something else happened.

    For learning more about bash scripting with lots of examples, google these:
    * Beginning Bash Scripting Guide
    * Advanced Bash Scripting Guide
    * man bash
    * Unix Power Tools


Posting Permissions

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