How I can replace this command --need help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How I can replace this command --need help
# 8  
Old 06-21-2007
You can try something like that (not tested) :
Code:
#!/bin/sh
path=C:/APPS/Tivoli/bin/w32-ix86/TME/TEC/scripts
while :
do
   if [ -f $path/cash.log ]
   then
      mv $path/cash.log $path/cash.new
      while read sms 
      do
         echo "#MSG#$sms" >>$path/output
      done < $path/cash.new
      rm $path/cash.new
   fi
done

# 9  
Old 06-21-2007
It is not working;

Hi,

It is not working; I can't rename the file (cash.log) because another script output always feed SMS messages into it

Thanks in advance
Regards
Sudhish
# 10  
Old 06-22-2007
You can't modify the file since another process is writing to it.
In fact, it's possible but it's impossible to guarantee the integrity of the file.

In which order do start the process reading the file and the manuscript reading this same file?
# 11  
Old 06-25-2007
Hi,

Sorry for the delay response.

This is what the scripts does.

My main script doesn't read the file cash.log, it only append SMS message to cash.log (messages format are given below).

Then the second script read the first line of cash.log ( i.e. first line “NOC-Alert:ITM_Linux_System_Statistics 06/25/2007 05:19:59-OPEN-CRITICAL-db21.1-High System thrashing - Pages paged in per second is 6518.00 and Pages paged out per second is 48.00”) send this to SMS modem (for testing new script I just redirect to $path/output)

Waite for some time and delete the first line from cash.log

Again it read the first line (this time second one i.e. NOC-Alert:APCupsOnBattery 06/25/2007 11:28:07 AM-OPEN-CRITICAL-chi2-APC(40KVA) UPS - A: UPS: On battery power in response to an input power problem) and execute the same

Second script will send SMS until cash.log become empty.

##############
$More cash.log

NOC-Alert:ITM_Linux_System_Statistics 06/25/2007 05:19:59-OPEN-CRITICAL-db21.1-High System thrashing - Pages paged in per second is 6518.00 and Pages paged out per second is 48.00
NOC-Alert:APCupsOnBattery 06/25/2007 11:28:07 AM-OPEN-CRITICAL-chi2-APC(40KVA) UPS - A: UPS: On battery power in response to an input power problem.
NOC-Alert:APCupsOnBattery 06/25/2007 12:52:50 PM-OPEN-CRITICAL-chi2-APC(40KVA) UPS - A: UPS: On battery power in response to an input power problem.
NOC-Alert:ITM_Linux_System_Statistics 06/25/2007 14:19:59-OPEN-CRITICAL-db02-High System thrashing - Pages paged in per second is 1710.00 and Pages paged out per second is 48.00.
NOC-Alert:ITM_ManagedSystem 06/25/2007 15:16:01-OPEN-FATAL-PW002-The Server Primary:PW002:NT is offline.
NOC-Alert:APCupsOnBattery 06/25/2007 03:31:22 PM-OPEN-CRITICAL-SNT01-APC(40KVA) UPS - A: UPS: On battery power in response to an input power problem.
NOC-Alert:APCupsOnBattery 06/25/2007 03:31:23 PM-OPEN-CRITICAL-PCSNT02-APC(40KVA) UPS-B: UPS: On battery power in response to an input power problem.
NOC-Alert:ITM_ManagedSystem 06/25/2007 15:16:01-OPEN-FATAL-PW002-The Server Primary:PW002:NT is offline.


Thanks in advance
Regards
Sudhish
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed Command to replace particular value.

Hi , My input file contain : list = 3 14 15 10 9 11 12 18 19 20 21 22 23 24 25 26 6 1 2 3 4 5 7 8 16 17 27 28 30 29 Expected output : list = 0 0 0 0 0 0 0 18 0 20 0 0 0 0 0 0 6 0 0 3 4 0 0 0 0 0 0 0 0 0 I want to keep the 8,10,16,17,22 value from the list and put 0 on rest of the... (9 Replies)
Discussion started by: Preeti Chandra
9 Replies

2. Shell Programming and Scripting

sed replace command

Hi. I need to append/prefix an & character to every 'single' & character (not when there are 2 or more grouped together) I find in a file. I can do it using this cmd: cat ${file} | sed -e 's/&/&&/g' > ${new_file} How can I modify this to ensure I only replace single &'s and not operate... (11 Replies)
Discussion started by: user052009
11 Replies

3. UNIX for Dummies Questions & Answers

Global replace command help

Hello - I am trying to use a global replace command but its not working. Here is the cmd I am using in vi: :%s/OLD/NEW/g However, in my "NEW" I already have a "/" which is not making the replace work: :%s/mytestscript.com:33232/mytestscript:70245/test.com/g the... (2 Replies)
Discussion started by: DallasT
2 Replies

4. UNIX for Dummies Questions & Answers

Replace command

Hi , I have a sequence which looks like this Lsat01000001 Lsat01000002 Lsat01000003 .. Lsat01000999 .. Lsat01100001 Lsat01278544 i want my output to look like this: seq1 seq2 seq3 ... seq999 (1 Reply)
Discussion started by: siya@
1 Replies

5. Shell Programming and Scripting

Please help replace character command

hi i have log : i want remove some char become like this: anybody can help me ? (7 Replies)
Discussion started by: justbow
7 Replies

6. Shell Programming and Scripting

find and replace command

Hi, i used to do on soalris box but in linux box i am not able to do advice is appreciated uname -a Linux intranet 2.4.20-pre3 #1 Tue May 6 17:55:35 IST 2008 i686 unknown $ find /usr/local/ -type f | xargs perl -pi -e 's/172.16.1.14/172.16.1.27/g' Can't remove /usr/local/bin/dbhome:... (1 Reply)
Discussion started by: prakash.gr
1 Replies

7. Shell Programming and Scripting

problem with replace command with tr

I have a sample file like this 7829885 7831552 + 1 1667, 0, 35934936 35937087 - 2 1281,870, 0,1281, I would like to replace values starts with comma with just value like 0, to 0 or 1667, to 1667. I can do with this by using tr -d '0,' '0' <file But the... (2 Replies)
Discussion started by: repinementer
2 Replies

8. UNIX for Dummies Questions & Answers

find and replace command in one line using one command

Hi, I have a entry in the file as ::BSNL GUJARAT::India::OUT::NAT::REWEL::POSTPAID::919426199995 if u see this, i have the delimiter as :: , all i want is to replace "::" as ":" so how to do that.. pls help thanks (10 Replies)
Discussion started by: vasikaran
10 Replies

9. UNIX for Dummies Questions & Answers

vi command - replace

Hi, Given a long text file. How can I replace all full stops- with semicolon thanks, tictactoe (1 Reply)
Discussion started by: tictactoe
1 Replies

10. UNIX for Dummies Questions & Answers

Command to replace character

I've been googling for the following for the past few weeks several times, but haven't yet come across something that I could easily grasp. Can someone point me in the right direction please? I'm trying to replace a character in file names, i.e. the character is a period, and I want to replace... (5 Replies)
Discussion started by: HLee1981
5 Replies
Login or Register to Ask a Question