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"
# 1  
Old 03-08-2014
HP-UX: Shell Script giving " 0^J30: Syntax error"

Hi All,
We are getting a very unique error while running a shell script on HP-UX box.
Can somebody help in this regards?

The shell script is working fine on linux/solaris box.

Error:
++++++++++++++++++++++++
Code:
$/test.sh
./test.sh[48]: 0^J30: Syntax error
$

++++++++++++++++++++++++

TIA.

PS: If required, can post the shell script.

Last edited by Scrutinizer; 03-08-2014 at 01:10 AM.. Reason: need to provide more info; [mod] code tags
# 2  
Old 03-08-2014
Yes that would be required, or at least the relevant section, anonymized if need be, and used with [code] tags.
This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 03-08-2014
Please see the full script:
(Note: it works on Linux, but gives the error on HP-UX)

Code:
 
#!/bin/sh

#=============================================================
# Variable Declaration
#=============================================================
server=`hostname`
configfile="$HOME/config_file"
flagfile="$HOME/flag_file"
mailfile="$HOME/mail_file"
tmpflagfile="$HOME/tmp_flag_file"
#=============================================================
cat abc|tail -n +5 |tr -s " "|sed '$d'|cut -d " " -f3,4 > ${configfile}
for queue in `cat ${configfile}|cut -d ' ' -f1`
do
   if [ $queue = "q_ft_out" ]
   then
      threshold=30
   else
      threshold=20
   fi
   size=`cat ${configfile}|grep "$queue"|cut -d " " -f2`
   if [ -f "${flagfile}" ]
   then
      x=`grep $queue ${flagfile} | wc -l`
      if [ "$x" -ge 1 ]
      then
         if [ "$size" -ge "$threshold" ]
         then
            echo " SERVER:$server       QUEUENAME:$queue             SIZE:$size " >> ${mailfile}
         else
           echo "`grep -v $queue ${flagfile}`" > ${tmpflagfile} && mv ${tmpflagfile} ${flagfile}
         fi
      else
        if [ "$size" -ge "$threshold" ]
        then
           echo "$server $queue $size" >> ${flagfile}
        fi
      fi
   else
   if [ "$size" -ge "$threshold" ]
   then
      echo "$server $queue $size" >> ${flagfile}
      fi
   fi
done
if [ -f ${mailfile} ]
then
cat ${mailfile} | mailx -s "TEST : Queues Which are Above Threshold on $server" "*****@*****"
#============================================================
# Remove Unwanted Files
#============================================================
rm ${mailfile}
fi

# 4  
Old 03-08-2014
Hmm, some UUOC but cannot see a syntax error.
Even not in line 48.
Were there some special characters?
Perhaps they were removed when you copied to this Wiki page?
Can you copy back to testnew.sh and run
Code:
diff test.sh testnew.sh

This User Gave Thanks to MadeInGermany For This Post:
# 5  
Old 03-08-2014
Thanks for checking.

Sorry: please dont conisider "line 48" as that giving the error.
Actaully, while copying the script on this page, I removed some comments and extra lines.
So, if I run the above code exactly without changes ON HP UX, I am getting the error on line 27.
Please see below.

Note:
I switch to another user (su) while running the script, might that be an issue?
Can you please guide how I can ensure that the user's profile and environment is not causing an issue?

Code:
>./test.sh
./test.sh[27]: 0^J30: Syntax error
>uname -a
HP-UX **** B.11.31 U ia64 0320060873 unlimited-user license

# 6  
Old 03-08-2014
Looks like your configfile has some special characters.
Can you paste the output of od -bc configfile

--ahamed
# 7  
Old 03-08-2014
Line 24 has an unquoted argument for grep that does an unwanted match against the current directory (and eventual replacement).
Please change it to this:
Code:
...
      x=`grep -c "$queue" ${flagfile}`
      if [ "$x" -ge 1 ]
...

Dito line 15. Please change to this:
Code:
   if [ "$queue" = "q_ft_out" ]
   then

Indeed the queue variable is fed from configfile that likely contains strange characters.

Last edited by MadeInGermany; 03-08-2014 at 03:28 PM..
This User Gave Thanks to MadeInGermany For This Post:
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