help needed urgently


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help needed urgently
# 1  
Old 02-07-2008
Question help needed urgently

hi all
i need help
I am confused and stucked. Actually i am new in this scripting stuff. I want to give complete txt file as a input to a variable and then sort the data in the file according to the alpha numeric characters, as my text file contains ! and !! and !!! indicating Minor, Major and Critical repectively. Each alpha numeric represent new entry. I am trying to do but all in vain, help needed plz,
codes which i am trying are as follows,

[code]:

#!/bin/bash
alarmfile= `cat ~/alkatel.txt`
[\code]

i tried so many times but whenever i try to take file as input by code above but i got the output

>> : command not found

its a long file ,im sending a part of this text file that i want to take as input

example of file

>> ALAIL;

CMD ALAIL 06095 08-01-30 11-58-23
INP ALAIL 06095 08-01-30 11-58-23
OPTEX=



RES ALAIL 06095 08-01-30 11-58-24
CEN=1/08-01-30/11 H 58 MN 19/STORED ALARMS LIST
PROCESSING TPFFIR ACC


! *A0628/540 /07-12-17/15 H 58/N=7598/TYP=ICT/CAT=SI/EVENT=MAL
/NCEN=MULCT /AM =SMTA1/AGEO=S1-TR01-B03-A085-R000
/TEXAL=AIS/COMPL.INF:
/AF=URMA1
/ ICTRQ AGCA=S1-TR01-B03-A112-R065
/AMET=01-07-02
/AFLR=222-09/CRC=NACT
!!! *A0628/303 /07-12-17/15 H 46/N=7501/TYP=COM/CAT=IM/EVENT=MAL
/NCEN=MULCT /AFUR =URAD- 4/AGEO=BUDLASAN-B01
/TEXAL=SINGLE JUNCT/UT OOS/COMPL.INF:
/CN=3

if i removed these >> operators from the start of file i again got the same output

ALAIL ; :command not found

even this file doesnt have executeable permission but still i am getting this message
i am so confused as i am still at my first step since 3 days
please help me, why it doesnt take the whole file as text input rather the first word and ignorin the rest of file

as i told befor ! & !!! showing minor & critical alarms.its a log file of alkatel switch & i have to extract

!!! , !! , !
with relevant
date & time e.g !!! */07-12-17/15 H 46/
event i.e. EVENT=MAL
& texal i.e. /TEXAL=SINGLE JUNCT/UT OOS/COMPL.INF

i collected stuff about reg exp from this site to take yhe substring but couldnt find a way still

let me make it very clear that i need this script in bash onlynot perl and any other language

i tried another script to extract entry components from the file as
Code:
:
#!/bin/bash
var=~/alkatel.txt
while read line $var
do
{
echo $line
}done

Smiliebut the out put became the infinite loop of the first line as

>> ALAIL; :command not found

can any one do it
waiting for reply soon
Smilie
# 2  
Old 02-07-2008
Error a bit longer part of file to be input to make u guys ver clear

file starts as follows

>> ALAIL;

CMD ALAIL 06095 08-01-30 11-58-23
INP ALAIL 06095 08-01-30 11-58-23
OPTEX=



RES ALAIL 06095 08-01-30 11-58-24
CEN=1/08-01-30/11 H 58 MN 19/STORED ALARMS LIST
PROCESSING TPFFIR ACC


! *A0628/540 /07-12-17/15 H 58/N=7598/TYP=ICT/CAT=SI/EVENT=MAL
/NCEN=MULCT /AM =SMTA1/AGEO=S1-TR01-B03-A085-R000
/TEXAL=AIS/COMPL.INF:
/AF=URMA1
/ ICTRQ AGCA=S1-TR01-B03-A112-R065
/AMET=01-07-02
/AFLR=222-09/CRC=NACT
!!! *A0628/303 /07-12-17/15 H 46/N=7501/TYP=COM/CAT=IM/EVENT=MAL
/NCEN=MULCT /AFUR =URAD- 4/AGEO=BUDLASAN-B01
/TEXAL=SINGLE JUNCT/UT OOS/COMPL.INF:
/CN=3


!!! *A0628/306 /08-01-23/07 H 20/N=9619/TYP=COM/CAT=IM/EVENT=MAL
/NCEN=MULCT /AFCN =CNLM3-4/AGEO=MKRASHID-B02-A003
/TEXAL=CN ISOLATED
!!! *A0628/303 /07-12-17/15 H 46/N=7503/TYP=COM/CAT=IM/EVENT=MAL
/NCEN=MULCT /AFUR =URAD- 12/AGEO=KHOTYWAL-B01
/TEXAL=SINGLE JUNCT/UT OOS/COMPL.INF:
/CN=0
!!! *A0628/089 /08-01-29/22 H 14/N=1760/TYP=ENP/CAT=IM/EVENT=MAL
/NCEN=MULCT /AFUR =URAD- 11/AGEO=QADIRPUR-B01
/TEXAL=GENERATING UNIT


!! *A0628/320 /08-01-17/13 H 47/N=8062/TYP=COM/CAT=ID/EVENT=MAL
/NCEN=MULCT /AFUR =URAL- 15/AGEO=S1-TR01-B04
/TEXAL=FAULTY UNIT/COMPL.INF:
* #F0612/T11F14/NCEN=MULCT /08-01-30/11 H 33/NAM=ODCAB /TDA=0001
/N=7064/NIV=2/ENS=006/SENS=013-000-000/P='0228'H/CN=02/PAR='03'H
/EM: AFUR =URAL- 15
!!! *A0628/303 /07-12-17/15 H 46/N=7506/TYP=COM/CAT=IM/EVENT=MAL
/NCEN=MULCT /AFUR =URAD- 7/AGEO=ADABOSAN-B01
/TEXAL=SINGLE JUNCT/UT OOS/COMPL.INF:
/CN=2


!!! *A0628/303 /07-12-17/15 H 46/N=7507/TYP=COM/CAT=IM/EVENT=MAL
/NCEN=MULCT /AFUR =URAD- 11/AGEO=QADIRPUR-B01
/TEXAL=SINGLE JUNCT/UT OOS/COMPL.INF:
/CN=2
!! *A0628/320 /08-01-26/06 H 39/N=0566/TYP=COM/CAT=ID/EVENT=MAL
/NCEN=MULCT /AFUR =URAD- 14/AGEO=KHOKARAN-B01
/TEXAL=FAULTY UNIT/COMPL.INF:
# 3  
Old 02-07-2008
Quote:
Originally Posted by nabmufti
while read line $var
I don't think read works this way.
Try:
Code:
cat $var | while read line

It appears from your error that you are inadvertantly executing the lines of the file rather than just reading them. Post your full script (use CODE and /CODE tags carefully to make it easier to read) and we'll take a look.
# 4  
Old 02-07-2008
Network

Quote:
Originally Posted by nabmufti
[code]:

#!/bin/bash
alarmfile= `cat ~/alkatel.txt`
not sure if intended or accidental but remove that space between = and `

#!/bin/bash

set -x
#alarmfile= `cat ~/alkatel.txt`
alarmfile=`cat ~/alkatel.txt`


also in your scripts you might add "set -x" to see the commands as they run to help debugging
# 5  
Old 02-08-2008
Question help needed to extract string components from a file by BASH script

actually i want you to have a complete understanding of my problem cozi am beginer & i am still stucked
Smilie

i have no problem with using space i.e

Code:
:
#!/bin/bash
alarm= `cat ~/alkatel.txt

or

Code:
:
#!/bin/bash
alarm=`cat ~/alkatel.txt

:

these codes display file contents which is fine but the main problem is to extract string components from file which i couldnt
plz read the first thread i posted in very much detail to help me
i realy need this help


waiting for your reply very soon

Last edited by nabmufti; 02-08-2008 at 08:59 AM.. Reason: to make code clear
# 6  
Old 02-08-2008
Quote:
alarm=`cat ~/alkatel.txt
Where is the closing ticks "`" ? Was that by mistake

Please refrain from usage of statements like
- Very urgent help
- waiting for your reply
# 7  
Old 02-08-2008
Question extract string components from a file by BASH script

following the script i got here worked well in getting file input

Code:
#!/bin/bash
alarm= `cat ~/alkatel.txt`
echo $alarm | while read line
do
{
echo $line
} 
done

thanx 4 itSmilie

but will you plz help me in extracting the whole string following ! , !! or !!!
coz i can only extract just one letter at my best using code

the example of file im trying to extract strings is given above

more i am trying to use cut command to extract string components in file.
can i use this command to extract a complete log of alarm from file e.g.


!!! *A0628/303 /07-12-17/15 H 46/N=7501/TYP=COM/CAT=IM/EVENT=MAL
/NCEN=MULCT /AFUR =URAD- 4/AGEO=BUDLASAN-B01
/TEXAL=SINGLE JUNCT/UT OOS/COMPL.INF:
/CN=3

i want to extract the string in this way above
i used the command cut to extract date and time from the file as
Code:
cut -b 16-32 ~/alkatel.txt

but i got the output as

/07-12-17/15 H 46/
T /AFUR =URAD- 4


hope u will understand my problemSmilie

please read the threads above , to be sure about solution of my problem
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need answers urgently!!

hello guys!! need 1 favour from u all.. Can u jst tell me the answers for these ques?? 1. ls - l _____ : command to return all files that end with single digit and those with TXT extension 2. ls -l report* _______ : command to return all files that start with the word RPT except those with LOG... (1 Reply)
Discussion started by: Gan_7
1 Replies

2. Shell Programming and Scripting

Help needed urgently. Look back for files in PERL

I have 3 variables $file =abc_2011_11_01.txt (current day file) $back = Yes $forward = No I need to search for 3 days back files / 3 days forward files if my current file is not present logic is, I need to download the current day file. If it is missing, i need to look out for... (1 Reply)
Discussion started by: irudayaraj
1 Replies

3. UNIX for Advanced & Expert Users

Please correct my script - Needed very urgently

hello all, I have a script, used to search for the strings from the set of 5 similar pattern file from the log dir. So here it goes . The input parameter is a part of the file name. When during the script execution, the script should parse the input parameter to original file's with the same... (1 Reply)
Discussion started by: raghunsi
1 Replies

4. Shell Programming and Scripting

Help need urgently....

I am new to shell scripting I am getting file sample.txt from mainframes to my unix machine Mon-Fri every 15 minutes from 9:00AM to 6:00PM. I need to Compare timestamp of sample.txt against system time via a Unix script kicked off by an Autosys job My Task is to write a shell script to monitor... (3 Replies)
Discussion started by: chinniforu2003
3 Replies

5. UNIX for Advanced & Expert Users

Help needed Urgently... Thanks in advance

You have a file called /opt/test/input.txt with the following information: man_aa_bld_100.410.040_CMD 08/14/2008 23:29:21 08/14/2008 23:31:10 SU 5339491/1 man_aa_bld_100.410.050_CMD 08/14/2008 23:29:21 08/14/2008 23:31:11 SU 5339491/1 man_aa_bld_100.410.060_CMD 08/14/2008 ... (3 Replies)
Discussion started by: jkumsi
3 Replies

6. Solaris

most urgently about pc-routing

Hi I have knowledge is a little about Solaris 10. I have problem route Question I have two lan interfaces nge0 >> 192.168.1.1 / 24 and link up Client1 >> 192.168.1.10 not out internet (GW 192.168.1.254) nge1 >> 192.168.50.220 /24 and link up Client50 >> 192.168.50.1 can... (2 Replies)
Discussion started by: sermsuk
2 Replies

7. UNIX for Dummies Questions & Answers

Help NEEDED urgently on exceutable file

Hi , i amtrying to execute a file called bcs_maint which is the final executable for our project. Normally on some other servers ican execute it by just typing bcs_maint. yesterday i got a new worksattion for me and when i do the same it says /sbin/sh: bcs_maint : not found. What... (5 Replies)
Discussion started by: jagan_kalluri
5 Replies

8. Shell Programming and Scripting

Need help urgently

Hi to All, I m a regular visitor of this site but this one is my first thread . Although I ve tried but I cant find the solution .:confused: I ve number of files having extension .file., which having some define statement in it.The files consits as follows Ex:- abc.file `define ADCONV0 ... (3 Replies)
Discussion started by: user_prady
3 Replies

9. UNIX for Dummies Questions & Answers

Major Help Urgently Needed!!!!

Right deleted Linux partition usig windows then went to format c:\ but had to exit window now pc ONLY boots into GNU Grub. Does anyone know how to format the hard drive now????? (3 Replies)
Discussion started by: billett05
3 Replies

10. Shell Programming and Scripting

Shell Script needed urgently

Hi Frends, I am need of a small shell script. Kindly any body help me by giving me a small shell script to read first line in a file and extract date from the first line and store it in a variable... and after storing it in a variable the first and the last line of the file has to be deleted..... (2 Replies)
Discussion started by: vas_dba
2 Replies
Login or Register to Ask a Question