Sponsored Content
Top Forums Shell Programming and Scripting When running if condition, getting the following error Post 302182217 by sunitachoudhury on Sunday 6th of April 2008 02:15:32 AM
Old 04-06-2008
When running if condition, getting the following error

Hi All,

My input file name is 1.sh

the contents of file are

cat status2.txt | while read filename
do
echo "$filename"
echo "first content of the file is ${filename[0]}"
echo "second content of the file is ${filename[0]}"
echo "second content of the file is ${filename[0]}"
if [ ${filename[0]} -eq 0 -a ${filename[1]} -eq 0 -a ${filename[2]} -eq 0 ]
then
echo "please execute the step 1, then step 2 and then step3"
elif [ ${filename[0]} -eq 0 ]
then
echo "please execute the step 2 and then step3"
elif [ ${filename[0]} -eq 0 -a ${filename[1]} -eq 0 -a ${filename[2]} -ne 0 ]
then
echo "please execute the last step3"
fi
done


Where status2.txt contains the following contents
0 --> first content is 0
0 --> Second content is 0
--> Third content is the space


Now running the 1.sh file i am getting the following output.

0
first content of the file is 0
second content of the file is 0
second content of the file is 0
./1.sh: [: too many arguments -------> Error
please execute the step 2 and then step3
0
first content of the file is 0
second content of the file is 0
second content of the file is 0
./1.sh: [: too many arguments -------> Error
please execute the step 2 and then step3

first content of the file is
second content of the file is
second content of the file is
./1.sh: [: too many arguments -------> Error
./1.sh: [: -eq: unary operator expected -------> Error
./1.sh: [: too many arguments -------> Error
dmadmin SYDUEND01 /tmp/A380_RFS24


can anybody tell me that why i am getting the above error??
It is very urgent, Please response me ASAP.

Thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Running scripts with condition

I have two scripts: SCR1 which takes between 5 seconds to 15 minutes and needs to be run every 23 minutes. SCR2 which needs to be run every 5 minutes but only if SCR1 is not running at that moment. How can I do this task? Best Regards /Hamid (3 Replies)
Discussion started by: Hamid Afsharazad
3 Replies

2. Shell Programming and Scripting

error in if-else condition

Hi.. Im using the following script to find whether the present day is monday or not. If it is monday it has to do a specific set of things. #!/bin/sh Present_Date=`date` LOAD_DAY=`date -d "$Present_Date" | cut -d " " -f 1` echo $LOAD_DAY if ;then echo "Monday" #statements;... (6 Replies)
Discussion started by: abala
6 Replies

3. UNIX for Dummies Questions & Answers

until loop : running even if condition is satisfied

I am checking one until loop with the following logic until || |||| do sleep 30 done before running this i am exporting above variables to SUCCESS.But the loop is running in infinite loop.My requirement is to make the loop run until all the 3 variables are SUCCESS or any of the 3... (2 Replies)
Discussion started by: dr46014
2 Replies

4. Shell Programming and Scripting

Error in if condition string comparison

Hello all! I need help in debugging following script. I have no idea where I am going wrong. #!/bin/bash for p1 in A1 TM MP do for p2 in A1 TM MP do for mp1 in N1 N2 do for mp2 in N1 N2 do for mp3 in N1 N2 do for mp4 in N1 N2 do for... (7 Replies)
Discussion started by: RLOA
7 Replies

5. Shell Programming and Scripting

Condition error!

Hi Guys, Can you please help me to check if my condition is correct. if && then if ; then # active SE_USERID_LUZON_5="A" elif ; then # not active SE_USERID_LUZON_5="D" ${ECHO_CMD}... (3 Replies)
Discussion started by: nikki1200
3 Replies

6. Shell Programming and Scripting

while condition error:

I'm trying to run following code: while do echo "Hello World" done but I'm getting error on first line: ./test: line 1: syntax error near unexpected token `(' can anyone please tell me who can i run this loop. Also please tell me what will be syntax of do while loop in case i... (11 Replies)
Discussion started by: kashif.live
11 Replies

7. UNIX for Dummies Questions & Answers

error in if condition

Hi All, I need to compare the header of the input files which can be comma demilited, tild(~) or Pipr(|) seperated file. I am comparing the file header by taking 1st row and comparing it with input row: Below is the actual code:(ksh script) if then echo $dat >>... (4 Replies)
Discussion started by: abhi_123
4 Replies

8. Shell Programming and Scripting

Error: if condition

please follow below code if ; then its giving me an error as "test1.sh: line 3: r=$(eval echo '$lck_'$TABLE != "") if can anyone tell me how to do inside if condition...with out use any variable.. TIA (6 Replies)
Discussion started by: gnnsprapa
6 Replies

9. Shell Programming and Scripting

If condition giving syntax error. Need help.

Hi, I have an if condition on executing it is giving syntax error as below: -------------------------------------------------------------------------------------- line 61: syntax error in conditional expression ./play_test.sh: line 61: syntax error near `]' ./play_test.sh: line 61: ` if... (2 Replies)
Discussion started by: ramki067
2 Replies

10. UNIX for Beginners Questions & Answers

If condition is not working and getting error

Hi Team, If condition is not working properly and getting below error # ./score1.sh Enter your score ('q' for quit): 102 Enter your score ('q' for quit): q ./score1.sh: line 9: q: integer expression expected Average is: 102%. Exit. Actual code # Calculate the average of given... (3 Replies)
Discussion started by: Torrid
3 Replies
gcore(1)							   User Commands							  gcore(1)

NAME
gcore - get core images of running processes SYNOPSIS
gcore [-pgF] [-o filename] [-c content] process-id... DESCRIPTION
The gcore utility creates a core image of each specified process. By default, the name of the core image file for the process whose process ID is process-id will be core.process-id. OPTIONS
The following options are supported: -c content Produces core image files with the specified content. The content description uses the same tokens as in coreadm(1M). The -c option does not apply to cores produced due to the -p or -g flags. -F Force. Grabs the target process even if another process has control. -g Produces core image files in the global core file repository with the global content as configured by coreadm(1M). The com- mand will fail if the user does not have permissions to the global core file repository. -o filename Substitutes filename in place of core as the first part of the name of the core image files. filename can contain the same tokens to be expanded as the paths in coreadm(1M). -p Produces a core image file in the process-specific location with the process-specific content for each process as config- ured by coreadm(1M). The command will fail if the user does not have permissions to the per-process core file repository. OPERANDS
The following operand is supported: process-id process ID EXIT STATUS
The following exit values are returned: 0 On success. non-zero On failure, such as non-existent process ID. FILES
core.process-id core images ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWtoo | +-----------------------------+-----------------------------+ |Interface Stability |See below. | +-----------------------------+-----------------------------+ Command Syntax is Evolving. Output Format(s) are Unstable. SEE ALSO
kill(1), coreadm(1M), setrlimit(2), core(4), proc(4), attributes(5) NOTES
gcore is unaffected by the setrlimit(2) system call using the RLIMIT_CORE value. SunOS 5.10 11 Feb 2004 gcore(1)
All times are GMT -4. The time now is 03:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy