Compilation error character is missing-UNIX shell script


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Compilation error character is missing-UNIX shell script
# 1  
Old 02-11-2017
Compilation error character is missing-UNIX shell script

Dear Friends,
Regarding Compilation error character is missing-unix shell script
I am new to unix shell script.

My requirement is --I need to find out 3 files in my UBM unix directory,if any one(CMUSER) file is available means,then i need to exit from my unix script,

Below is my unix shell script logic and need to check with you guys why I am getting compilation error( mentioned all details). please answer specific to my question..

Code:
cd /$UBCS
if [ -f /$UBM/CSUSER.LOCKED -o -f /$UBM/CSUSER.START]
     -o f /$UBM/CSUSER.UPDATE ];
then
   exit;
fi

my compilation error below
===================

Code:
Enter script to execute: atm-autopbf
/rd23/gilbat/R2016/ubcs/atm-autopbf[38]: test: 0403-021 **A ] character is missing**
.
/rd23/gilbat/R2016/ubcs/atm-autopbf**[39]: -o:  **not found.****

 Not running C/S (SHELMATE MAXSESSIONS=0). Aborting ...

Press <ENTER> to continue:

Moderator's Comments:
Mod Comment Please take care to start threads in there proper forum. Moved to "UNIX for Beginners Questions & Answers"

Last edited by Scrutinizer; 02-11-2017 at 07:35 AM.. Reason: code tags
# 2  
Old 02-11-2017
There are several things:
  • There should be a space before the closing ], anyway it should not be there
  • A minus sign is missing before -f
  • The last part is on a new line, so it either should be one line above or the should be a backslash as the last character on the line before


--
Note: The use of -o in test commands is deprecated. Consider using something like:

Code:
if
  [ -f "/$UBM/CSUSER.LOCKED" ] ||
  [ -f "/$UBM/CSUSER.START"  ] ||
  [ -f "/$UBM/CSUSER.UPDATE" ]
then

# 3  
Old 02-11-2017
The reason the [ and ] characters have be set apart is that they are actually commands in terms of how the shell interprets them. Like awk or find.

For example on most systems if you use ls to list files in your /bin directory
Code:
$  ls -l /bin/[  
-rwxr-xr-x 1 Owner None 64019 Dec 16 15:54 '/bin/['

You will see a file that is named [ . Weird, I know, but it is a command and needs spaces around it like any other self-respecting word.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Error in ksh script: missing right bracket

I have no idea how to write ksh script, but i'm really in need of help with this. I using fedora 30 and in attempt of runnig attached script i getting those errors, i solved first error by removing excess bracket, but i do not know what should i do with other. Pls sorry for trash post. (8 Replies)
Discussion started by: NullPtr
8 Replies

2. Shell Programming and Scripting

UNIX shell script error: not found

Hello All, I'm working on one Unix shell sript that will actually extract a column data from Oracle table using sqlplus and writes onto a file. I'm getting this error when executing the shell script: rpt.ksh: ^JScott: not found Below is the code in the shell script: `sqlplus -s... (1 Reply)
Discussion started by: venkat_reddy
1 Replies

3. UNIX for Advanced & Expert Users

Checking missing data's sequence (shell script | UNIX command)

Dear All members, i have some trouble here, i want to ask your help. The case is: I have some data, it's like: -ABCD1234 -ABCD1235 -ABCD1237 -BCDE1111 -BCDE1112 -BCDE1114 there is some missing data's sequence (the format is: ABCD = name 1234 = sequence). I want to print the... (2 Replies)
Discussion started by: septian.tri
2 Replies

4. Shell Programming and Scripting

Syntax Error in Unix Shell Script

I am trying to run a unix script in my home directory.Snippet below echo "`date '+%Y%m%d_%H%M%S'` Getting ProductList.dat" if ( -f $DIR/ProductList.dat) then cp $DIR/ProductList.dat MigratedProductList.dat else echo "`date '+%Y%m%d_%H%M%S'`ProductList.dat does not exist; Processing... (4 Replies)
Discussion started by: Mary James
4 Replies

5. UNIX for Dummies Questions & Answers

Mailx command in unix shell script, its throwing below error

How to use Mailx command in unix shell script, its throwing below error #!/bin/ksh let x=3 If ; then mailx -s “ $x is greater than 2” example@gmail.com << EOF This is the message body EOF fi its throwing error as syntax error at EOF... (10 Replies)
Discussion started by: only4satish
10 Replies

6. Solaris

[Unix Solaris11] RPM2PKG error about compilation.

Hi, I'm new on this forum. I'm working on Solaris 11 (Express Edition) and I must install some programm created only for RedHat system (I don't want to buy or download RedHat). So I search for this tools and I find a working script for Solaris 9 and 10, but I need that for Solaris 11. So I search... (1 Reply)
Discussion started by: Fraste_
1 Replies

7. Shell Programming and Scripting

Shell script simple if then :: fi missing ]

If file exists then do stuff else do nothing... #! /bin/sh if then rm /home/dudemgnt/public_html/fileserver/Checks/Daily/RefundChecksDaily.csv cat /home/dudemgnt/public_html/fileserver/Checks/Daily/RefundChecksDaily*.txt|sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' >... (4 Replies)
Discussion started by: Astrocloud
4 Replies

8. Shell Programming and Scripting

Missing ] error in csh script

The below script gives error: Missing ] #!/bin/csh set MAX=15 set PATTERN='dtsession' set NUM=`ps -eaf | grep -c $PATTERN` echo "No of dtsession = "$NUM if then echo 'Quota exceeded permissible limit' echo 'sending mail...............' mail hiten.r.chauhan@gmail.com<<EOF ... (2 Replies)
Discussion started by: hiten.r.chauhan
2 Replies

9. Shell Programming and Scripting

Error while using sqlplus command inside 'if' condition in an unix shell script

Hi all, I am using the below given sqlplus command in my unix script to invoke a stored procedure which returns a value .It works fine. RET_CODE=$(/opt/oracle/product/10.2.0.4.CL/bin/sqlplus -S $USER/$PASSWD@$DB_NAME <<EOF EXEC MY_PKG.MY_SP (:COUNT); PRINT COUNT; commit; ... (6 Replies)
Discussion started by: Shri123
6 Replies

10. Shell Programming and Scripting

Bash script error: missing destination file name operand.

Ok, i've been messing around in debian the past few days, setting up programs like subversion, mysql and logrotate. The purpose of this script is to use subversion to backup the binary logs. It runs in the cron every 2 hours or so (although I can't get my script to run properly atm, which is why... (1 Reply)
Discussion started by: cganly
1 Replies
Login or Register to Ask a Question