linux - Bash script to execute commands on system boot up -
i trying make bash script check 2 data values , weather or not set 1 or 0 want something. these values set on system bootup , defined after system (that why using while loop keep checking until defined):
so far have this, getting error:
#!/bin/bash shopt -s expand_aliases alias gd126='gdget 126' # output either 1 or 0 alias gd3='gdget 3' # output either 1 or 0 alias gd5='gdset 5 1' # set data 1 gd126 gd3 while true; if [ gd126 -eq 0 ] && [ gd3 -eq 1 ]; gd5; break; fi; done
here output when run myscript.sh:
[root@server tmp]# ./myscript.sh 0 0 ./myscript.sh: [: gd126: integer expression expected ./myscript.sh: [: gd126: integer expression expected
could please tell me why? tried changing '-eq' '==' , stalls there no output.
there no happy ending when using aliases, not in scripts. use functions instead. in case, use "$(somecommand)"
if want output of command, not not command name itself:
#!/bin/bash gd126() { gdget 126 } if [ "$(gd126)" -eq 0 ] echo "it's 0" fi
Comments
Post a Comment