Too many arguements error in SH script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Too many arguements error in SH script
# 1  
Old 01-20-2015
Too many arguements error in SH script

Getting this error:
Code:
./check_db_locks.sh SAMPLE
./check_db_locks.sh: line 39: [: too many arguments
0&DB2 - None applications in lock-wait state
 
if [ $locks -ne 0 -a $lockwait -gt 60000 ] ; then
        lockids=`db2 get snapshot for locks on $1 |grep "ID of agent holding lock" |awk -F"= " '{print $2}' |sort -u`
        echo "$STATE_CRITICAL&DB2 - $locks lock(s). Possible app. handles are: $lockids"
        exit $STATE_CRITICAL
else
        echo "$STATE_OK&DB2 - None applications in lock-wait state"


Last edited by vbe; 01-20-2015 at 03:57 PM.. Reason: code tags
# 2  
Old 01-20-2015
Try quoting the variables.
Try using [ ] && [ ] instead of [ -a ].
# 3  
Old 01-20-2015
Thanks RudiC! Works perfectly!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calling shell script within awk script throws error

I am getting the following error while passing parameter to a shell script called within awk script. Any idea what's causing this issue and how to ix it ? Thanks sh: -c: line 0: syntax error near unexpected token `newline' sh: -c: line 0: `./billdatecalc.sh ... (10 Replies)
Discussion started by: Sudhakar333
10 Replies

2. UNIX for Dummies Questions & Answers

Re: Script Error [syntax error at line]

Hi , I Have Written A Simple Script To Check Greatest Of '2' Number When Execuating The Script I Am Getting The Below Error SP11: if:not found SP11: line 4:syntax error at line 5:'then' unexpexted And The Program I Have Wrriten For This #!bin/ksh echo "Enter Two Numbers"... (3 Replies)
Discussion started by: anudeepkumar123
3 Replies

3. Shell Programming and Scripting

Syntax error calling TCL script from shell script

hello everyone i am beginner on shell scripting .and i am working on my project work on ad hoc network i wrote a batch (.sh) to do a looping and execute a tcl script i wrote before in each iteration ..but i got this problem " syntax error near unexpected token `('... (1 Reply)
Discussion started by: marcoss90
1 Replies

4. Shell Programming and Scripting

How to grep sql error in shell script and exit the script?

I need help in the following script. I want to grep the sql errors insert into the error table and exit the shell script if there is any error, otherwise keep running the scripts. Here is my script #!/bin/csh -f source .orapass set user = $USER set pass = $PASS cd /opt/data/scripts echo... (2 Replies)
Discussion started by: allinshell99
2 Replies

5. Windows & DOS: Issues & Discussions

Error opening script file - location error

Hello, I know nothing about UNIX, ftp, etc. I am building an excel VBA macro which calls a .bat file. I've taken a pre-existing batch file and am trying to modify it to fit my purposes. I would be very grateful for some assistance. Here is my .bat file: echo off set... (9 Replies)
Discussion started by: starcraftbud
9 Replies

6. Shell Programming and Scripting

Script with error output but continuation in script?

I have written a basic fetching script. The script logs into an FTP site, downloads a .zip file, then unzips and moves the files to the necessary folders, then deletes them, etc. The problem I have is if one of the files no longer exists on the FTP site or another part of the script fails, then... (3 Replies)
Discussion started by: daem0n
3 Replies

7. Linux

problem in Passing arguements to pthread_create

Hello every one My question may look very easy, sorry for my ignorance. I am not able to figure the problem. #include<stdio.h> #include<stdlib.h> #include<pthread.h> void *myfunc(void *vptr_value) { int value = *((int *)vptr_value); printf("Thread value: %d \n", value); ... (1 Reply)
Discussion started by: praveenpvs
1 Replies

8. 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

9. Shell Programming and Scripting

pass input arguements to DB2 SQL script

Hi all, I have a shell script which invoke a sql script using command db2 -tf /home/me/db_housekeep.sql -z /home/me/db_housekeep.log however, this mentioned sql script requires several input arguments, I wonder if one can pass variables from shell script to sql script? thanks! (0 Replies)
Discussion started by: mpang_
0 Replies

10. UNIX for Dummies Questions & Answers

find files and using them as input arguements for another command

I need to do the following: 1) find files in certain directories that have todays date stamp 2) use these files as input arguements into another command (1 Reply)
Discussion started by: bobbygrep
1 Replies
Login or Register to Ask a Question