Results 1 to 2 of 2
I'm trying to make a script where the contents of a file are used as the trigger for what needs to be done
I used to do it with running ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-11-2011 #1Just Joined!
- Join Date
- Oct 2011
- Posts
- 1
Bash script - switch on filecontent
I'm trying to make a script where the contents of a file are used as the trigger for what needs to be done
I used to do it with running a php script, but my new box doesn't have php on it (and putting it on is not an option)
My php script:
Code:$trigger = file_get_contents('trigger.txt') switch ($trigger) { case 'update': // update command break; case 'reset': // reset command break; default: // default command }
Any suggestions to have a similar functionality in a bash script?
Thanks
KJ
- 10-12-2011 #2Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,696
Code:#!/bin/bash trigger=$(cat trigger.txt) case $trigger in 'update') # update command ;; 'reset') # reset command ;; *) # default command esac exit $?


Reply With Quote
