In addition to suggested checkscript the script, there are a couple more in the original script:
Code:
grep -En '==|\[\[|\[[0-9@]\]|=\(|\$\[|=~' script
80: if [ ! "x$curl" == "x" ];then
118: if [ $2 ] && [ "$status" == "0" ];then
156:if [ "x$url" == "x" -o "x$token" == "x" ]
162:if [[ `which curl` =~ "/curl" ]]
166:if [[ `which wget` =~ "/wget" ]]
171:if [[ ! $curl && ! $wget ]];
180: if [ "$host" == "" ] || [ "$State" == "" ]; then
200: arr=($line)
201: if [ ${#arr[@]} != 0 ];then
202: if [[ ${#arr[@]} < 3 ]] || [[ ${#arr[@]} > 4 ]];then
203: echo "ERROR: STDIN must be either 3 or 4 fields long, I found "${#arr[@]}
205: if [ ${#arr[@]} == 4 ]; then
207: <servicename>${arr[1]}</servicename>
208: <hostname>${arr[0]}</hostname>
209: <state>${arr[2]}</state>
210: <output>${arr[3]}</output>"
213: <hostname>${arr[0]}</hostname>
214: <state>${arr[1]}</state>
215: <output>${arr[2]}</output>"
219: checkcount=$[checkcount+1]
replace all echo statements with:
Code:
printf "%s\n" "some line"
replace
Code:
echo -e "string"
with
Code:
printf "string"
--edit--
annotated:
Code:
80: if [ ! "x$curl" == "x" ];then # single =
118: if [ $2 ] && [ "$status" == "0" ];then # single =
156:if [ "x$url" == "x" -o "x$token" == "x" ] # single =
162:if [[ `which curl` =~ "/curl" ]] # use case statement test for */curl* or use type statement instead of which
166:if [[ `which wget` =~ "/wget" ]] # use case statement test for */wget* or use type statement instead of which
171:if [[ ! $curl && ! $wget ]]; # if [ ! $curl ] && [ ! $wget ]
180: if [ "$host" == "" ] || [ "$State" == "" ]; then # single =
200: arr=($line) # set -- $line
201: if [ ${#arr[@]} != 0 ];then # if [ $# != 0 ]; then
202: if [[ ${#arr[@]} < 3 ]] || [[ ${#arr[@]} > 4 ]];then # if [ $# -lt 3 ] || [ $# -gt 4 ]
203: echo "ERROR: STDIN must be either 3 or 4 fields long, I found "${#arr[@]} # printf "%s\n" "ERROR ... I found $#"
205: if [ ${#arr[@]} == 4 ]; then # if [ $# -eq 4 ]; then
207: <servicename>${arr[1]}</servicename> # <servicename>${2}</servicename>
208: <hostname>${arr[0]}</hostname> # <hostname>${1}</hostname>
209: <state>${arr[2]}</state> # <state>${3}</state>
210: <output>${arr[3]}</output>" # etc...
213: <hostname>${arr[0]}</hostname>
214: <state>${arr[1]}</state>
215: <output>${arr[2]}</output>"
219: checkcount=$[checkcount+1] # checkcount=$((checkcount+1))
Last edited by Scrutinizer; 02-25-2015 at 03:29 PM..
This User Gave Thanks to Scrutinizer For This Post:
Hi,
I have to write a program to compare 2 files for copying.
the program is ran on Solaris 5.8 like this:
script.sh file1.txt file2.txt
I wrote the program using bash and it took me forever since I am a beginner but it works very well.
I'm getting so close to the deadline and I... (2 Replies)
Hi,
For my bash script, terminal with bash is generate an OK output and program works right.
already,
terminal with ash have "line 48: syntax error: Bad substitution" output and program don't work.
:confused: (0 Replies)
can any body translate the follwing script into one that works in bash?
#!/usr/bin/perl
# classify_books.pl
my $csv_file = shift;
my %categories = ( 'childrens' => 'childrens_books.txt',
'horror' => 'horror_books.txt',
'sports ' =>... (3 Replies)
Guys
I now have a script that's working in a BASH environment, however one line doesn't appear to be working on an embedded device that has a busybox therefore ASH shell. I've googled but there's very little I can find regarding the ASH shell.
In BASH the following line works...
if ] ;... (6 Replies)
dear all,
i need your advice for convert bash shell to C programming
INDEX=/zpool1/NFS/INDEX/${1}
SCRIPT=/zpool1/NFS/script/${1}
LIST=SAMPLE
cd ${SCRIPT}
for i in `cat ${LIST}`
do
GETDATE=`echo ${i}|awk '{print substr($1,9,8)}'`
/usr/xpg4/bin/awk -F ":" '{close(f);f=$4}{print >>... (2 Replies)
Hi All,
I have a script that I wrote on a bash shell, I use it to sort files from a directory into various other directories. I have an variable set, which is an array of strings, I then check each file against the array and if it is in there the script sorts it into the correct folder.
But... (5 Replies)
I wrote Bash script and now I want to convert it to Ash. One headache is this function:
do_adduser() {
setaddprompt
_arr_add=("Add manually" "Add via TXT" "return to main menu" "exit program")
select add_action in "${_arr_add}"
do
case "$REPLY" in
1)... (7 Replies)
I'm trying to convert this working bash script into an Ash script,
read -p "Username:" _username
if ! ]]; then
echo "Valid"
else
echo "INVALID"
fi
However, Ash does not recognize the "=~" character.
How can I do this?
Also, is there a good reference guide, so I... (5 Replies)
I am using bash that when run downloads a file a verifies that there is data in it. What I am not able to do is have a user enter a date in any format they wish and have it converted to m-d-yyyy. Thank you :).
Bash
printf " Welcome to NGS analysis, checking for new files and creating a... (2 Replies)