HP-UX: Shell Script giving " 0^J30: Syntax error"


 
Thread Tools Search this Thread
Operating Systems HP-UX HP-UX: Shell Script giving " 0^J30: Syntax error"
# 8  
Old 03-08-2014
Hi All,

Please see the output of "od -bc configfile"

Code:
0>od -bc config_file
0000000   t   e   l   l   a   b   s   7   1   0   0       0  \n   t   e
        164 145 154 154 141 142 163 067 061 060 060 040 060 012 164 145
0000020   l   l   a   b   s   7   1   0   0   N       3   0  \n   t   e
        154 154 141 142 163 067 061 060 060 116 040 063 060 012 164 145
0000040   m   s   _   x   m   l   _   i   f   _   s   n   d   _   q
        155 163 137 170 155 154 137 151 146 137 163 156 144 137 161 040
0000060   0  \n   q   _   f   t   _   o   u   t       4   0   0   0  \n
        060 012 161 137 146 164 137 157 165 164 040 064 060 060 060 012
0000100   z   h   o   n   e   A   r   c   a   d   a   c   s       0  \n
        172 150 157 156 145 101 162 143 141 144 141 143 163 040 060 012
0000120


Last edited by Scrutinizer; 03-09-2014 at 12:02 AM.. Reason: correcting the output
# 9  
Old 03-08-2014
Please correct the code tags, it is difficult to read.
Also, paste the output of sh -x yourscript
This User Gave Thanks to ahamed101 For This Post:
# 10  
Old 03-08-2014
Hello,

I made the below changes, but I getting the same error on line 27.

Code:
x=`grep -c "$queue" ${flagfile}`
...
...
if [ "$queue" = "q_ft_out" ]

# 11  
Old 03-08-2014
Please paste the output of
Code:
sh -x yourscript

The code tags you are using is wrong, it is a forward slash
# 12  
Old 03-08-2014
output of sh -x <script>

Code:
>sh -x test.sh
+ + hostname
server=******
+ configfile=/home/spgroup/sup/config_file
+ flagfile=/home/spgroup/sup/flag_file
+ mailfile=/home/spgroup/sup/mail_file
+ tmpflagfile=/home/spgroup/sup/tmp_flag_file
+ cut -d   -f3,4
+ sed $d
+ cat abc
+ tail -n +5
+ tr -s
+ 1> /home/spgroup/sup/config_file
+ cat /home/spgroup/sup/config_file
+ cut -d   -f1
+ [ tellabs7100 = q_ft_out ]
+ threshold=20
+ + cat /home/spgroup/sup/config_file
+ cut -d   -f2
+ grep tellabs7100
size=0
30
+ [ -f /home/spgroup/sup/flag_file ]
+ + grep -c tellabs7100 /home/spgroup/sup/flag_file
x=1
+ [ 1 -ge 1 ]
+ [ 0
30 -ge 20 ]
test.sh[27]: 0^J30: Syntax error
+ grep -v tellabs7100 /home/spgroup/sup/flag_file
+ echo lhprod18 q_ft_out 4000
+ 1> /home/spgroup/up/tmp_flag_file
+ mv /home/spgroup/sup/tmp_flag_file /home/spgroup/sup/flag_file
+ [ tellabs7100N = q_ft_out ]
+ threshold=20
+ + cat /home/spgroup/sup/config_file
+ cut -d   -f2
+ grep tellabs7100N
size=30
+ [ -f /home/spgroup/sup/flag_file ]
+ + grep -c tellabs7100N /home/spgroup/sup/flag_file
x=0
+ [ 0 -ge 1 ]
+ [ 30 -ge 20 ]
+ echo lhprod18 tellabs7100N 30
+ 1>> /home/spgroup/sup/flag_file
+ [ tems_xml_if_snd_q = q_ft_out ]
+ threshold=20
+ + cat /home/spgroup/sup/config_file
+ cut -d   -f2
+ grep tems_xml_if_snd_q
size=0
+ [ -f /home/spgroup/sup/flag_file ]
+ + grep -c tems_xml_if_snd_q /home/spgroup/sup/flag_file
x=0
+ [ 0 -ge 1 ]
+ [ 0 -ge 20 ]
+ [ q_ft_out = q_ft_out ]
+ threshold=30
+ + cat /home/spgroup/sup/config_file
+ grep q_ft_out
+ cut -d   -f2
size=4000
+ [ -f /home/spgroup/sup/flag_file ]
+ + grep -c q_ft_out /home/spgroup/sup/flag_file
x=1
+ [ 1 -ge 1 ]
+ [ 4000 -ge 30 ]
+ echo  SERVER:lhprod18       QUEUENAME:q_ft_out             SIZE:4000
+ 1>> /home/spgroup/sup/mail_file
+ [ zhoneArcadacs = q_ft_out ]
+ threshold=20
+ + cat /home/spgroup/sup/config_file
+ cut -d   -f2
+ grep zhoneArcadacs
size=0
+ [ -f /home/spgroup/sup/flag_file ]
+ + grep -c zhoneArcadacs /home/spgroup/sup/flag_file
x=0
+ [ 0 -ge 1 ]
+ [ 0 -ge 20 ]
+ [ -f /home/spgroup/sup/mail_file ]
+ mailx -s TEMS : Queues Which are Above Threshold on lhprod18 *****@*****
+ cat /home/spgroup/sup/mail_file
+ rm /home/spgroup/sup/mail_file

# 13  
Old 03-08-2014
The grep command is getting 2 values for tellabs7100
Code:
0 for tellabs7100
30 for tellabs7100N

and that is why the value 0^J30 is seen, ^J is actually unix line feed.

Since grep-ing for tellabs7100 will match both the lines containing tellabs7100 and tellabs7100N.

Add the switch -w to the grep statement.
Code:
...
size=`grep -w "$queue" ${configfile} | cut -d " " -f2`
...

And try to avoid the UUoC

Last edited by ahamed101; 03-08-2014 at 07:36 PM..
These 2 Users Gave Thanks to ahamed101 For This Post:
# 14  
Old 03-08-2014
I made the below change and the script ran fine...!

Thank you all for your time; pointing out the issues and getting it resolved.

Smilie

will remember to check UUOC from next time...

Code:
size=`grep -w "$queue" ${configfile} | cut -d " " -f2`

Thanks Again..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. BSD

Keep getting error "-bash: ./.profile_z2: line 52: syntax error: unexpected end of file"

#!/bin/bash #-------------------------------------------------------- # Setup prompt # Author Zeeshan Mirza # Data: 06-08-2017 #-------------------------------------------------------- if then . ./.profile_custom_pre fi umask 022 set -o vi export EDITOR=vi export VISUAL=vi... (3 Replies)
Discussion started by: getzeeshan
3 Replies

3. Shell Programming and Scripting

Bash Script giving "Command Not found"

Hello Geeks, Greetings...I have the following script: #!/usr/bin/bash #Script to generate number of active PDP context & calculate PDP activation #failurefrom EPG-M #Script written by Gbenga Adigun #September 12, 2013 username="xxxxxx" password="xxxxxxxxx" HOSTS=( ggsn01... (6 Replies)
Discussion started by: infinitydon
6 Replies

4. Shell Programming and Scripting

Help with FTP Script which is causing "syntax error: unexpected end of file" Error

Hi All, Please hav a look at the below peice of script and let me know if there are any syntax errors. i found that the below peice of Script is causing issue. when i use SFTP its working fine, but there is a demand to use FTP only. please find below code and explain if anything is wrong... (1 Reply)
Discussion started by: mahi_mayu069
1 Replies

5. Shell Programming and Scripting

read -n1 -r -p "Press..." key / produces error in bash shell script

Hello! Sorry, for my not so perfect english! I want to stop bash shell script execution until any key is pressed. This line in a bash shell script read -n1 -r -p "Press any key to continue..." key produces this error When I run this from the command line usera@lynx:~$ read... (4 Replies)
Discussion started by: linuxinho
4 Replies

6. Shell Programming and Scripting

ksh-script "arithmetic syntax error" comparing strings

Hi all, Iīve already searched the forum but canīt find what i am doing wrong. I am trying to compare two variables using ksh under red hat. The error I get is: -ksh: .: MDA=`md5sum /tmp/ftp_dir_after_transfer | cut -d' ' -f1 ` MDB=`md5sum /tmp/ftp_dir_before_transfer | cut -d' ' -f1 `... (3 Replies)
Discussion started by: old_mike
3 Replies

7. AIX

"too big" and "not enough memory" errors in shell script

Hi, This is odd, however here goes. There are several shell scripts that run in our production environment AIX 595 LPAR m/c, which has sufficient memory 14GB (physical memory) and horsepower 5CPUs. However from time to time we get the following errors in these shell scripts. The time when these... (11 Replies)
Discussion started by: jerardfjay
11 Replies

8. Shell Programming and Scripting

In ksh shell command - Print "-ABC" is giving error

Hi Guys, while executing the following command : print "-ABC" is giving following error : ksh: print: bad option(s) I cannot use echo for some other reasons, so any other option ? (2 Replies)
Discussion started by: sagarjani
2 Replies

9. UNIX for Dummies Questions & Answers

awk Shell Script error : "Syntax Error : `Split' unexpected

hi there i write one awk script file in shell programing the code is related to dd/mm/yy to month, day year format but i get an error please can anybody help me out in this problem ?????? i give my code here including error awk ` # date-month -- convert mm/dd/yy to month day,... (2 Replies)
Discussion started by: Herry
2 Replies

10. Shell Programming and Scripting

"syntax error at line 21 :'done' unexpected." error message"

I am trying to run the script bellow but its given me "syntax error at line 20 :'done' unexpected." error message" can someone check to see if the script is ok? and correct me pls. Today is my first day with scripting. Gurus should pls help out #!/bin/ksh # Purpose: Check to see if file... (3 Replies)
Discussion started by: ibroxy
3 Replies
Login or Register to Ask a Question