The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help NEEDED urgently on exceutable file jagan_kalluri UNIX for Dummies Questions & Answers 5 05-29-2008 04:06 PM
Need help urgently user_prady Shell Programming and Scripting 3 09-03-2007 10:51 PM
Major Help Urgently Needed!!!! billett05 UNIX for Dummies Questions & Answers 3 07-20-2005 03:55 PM
Need Information Urgently. sumit_krishan UNIX for Dummies Questions & Answers 3 06-08-2005 07:13 AM
Shell Script needed urgently vas_dba Shell Programming and Scripting 2 03-11-2005 09:00 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-07-2008
nabmufti nabmufti is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 15
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
but 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
  #2 (permalink)  
Old 02-07-2008
nabmufti nabmufti is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 15
Exclamation 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 (permalink)  
Old 02-07-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
Quote:
Originally Posted by nabmufti View Post
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 (permalink)  
Old 02-07-2008
HPAVC's Avatar
HPAVC HPAVC is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 106
Angry

Quote:
Originally Posted by nabmufti View Post
[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 (permalink)  
Old 02-08-2008
nabmufti nabmufti is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 15
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


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 (permalink)  
Old 02-08-2008
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,953
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 (permalink)  
Old 02-08-2008
nabmufti nabmufti is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 15
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 it

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 problem

please read the threads above , to be sure about solution of my problem
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:28 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0