three shell script questions
hi
here is three questions everybody will enjoy . and of course me. 1->i'm runnig a command in my shell script and i want to break this command if it doesn't return any return code or response in a certain time. For example: i'm running tnsping command. if it does't return any response in 20 seconds, i want my script to echo an error mesage and to resumes its work. how i can achive this contol in my script. 2-> i got a while block as follows, cat $DBASEFILE | while read LINE do CONTROLDB=`echo $LINE| cut -d: -f1` RESULT=`tnsping $CONTROLDB | grep 'OK' ` if [ $? -eq 0 ] then echo "$LINE ---> $RESULT" continue else CONTROLIP=`echo $LINE| cut -d: -f2` CONTROLSID=`echo $LINE| cut -d: -f4` done here DBASEFILE is a file store my database information. and i use tnsping to control databases connectivity. and the question: i want to run 'tnsping $CONTROLDB' command at the background. while it is runnig it want to run the next 'tnsping $CONTROLDB'command with out concerned the result of the first 'tnsping $CONTROLDB'. ıs there a way to achive this control. 3->i got a log file: it context is like follow, {sms} {90544} {90544258} {905358258} {7506} {sms} {905438} {null} {1234} {9054329017} {chat} {NA} {sms} {9054528} {sms} {90543528} {null} {1234} {90593522} {chat} {NA} {sms} {90571528} {null} {1234} {90546203} {chat} {NA} {sms} {905471528} {null} {1234} {90546777} {chat} {NA} {sms} {905471528} {null} {1234} {905466861} {chat} i want do divede every line as follows part. {sms} {905438} {90544258} {905358258} {7506} i can do with some control loops. bu i am interested that is there a any simple way to perform this task. by the way, some times there are over the 1200 world in the {}. so awk isn't not a good choice for this task. Thanks for your patience. |
3-> This is easy:
for i in $(<logfile);do echo $i;done 1-> This is a little harder: Code:
#!/bin/bash 2-> I'm not sure I understand this question. You want to run tnsping more than once in background? <command1> & #command1 running in background PROCESS1=$! #$PROCESS1 is the pid of command1 <command2> & #command2 running in background PROCESS2=$! #$PROCESS2 is the pid of command2 wait #Don't do any more processing until all background processes complete. |
Quote:
for example: {word1} {word1} {word1,word2,...wordn} Quote:
Quote:
i want to run many commands at the background in a while LOOP and send the result of the these commands in the a log file. when one of these commands are running at the background and sending it result the log file, i want to CONTINUE the while LOOP for the next command that will run at the background. |
Quote:
sed 's/} /}\n/g' logfile Quote:
Code:
#!/bin/bash |
Quote:
{sms}n{90571528}n{null}n{1234}n{90 54 6203}n{chat}n{NA} Quote:
thaks for your help. |
All times are GMT -5. The time now is 07:53 PM. |