syntax error, need to redo one line in script :(

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting syntax error, need to redo one line in script :(
# 1  
Old 01-10-2008
syntax error, need to redo one line in script :(

I have a script that processes a file with two columns (IDs and Idle session times):

# cat /tmp/idle-ids.lst
user1 2,390
user2 97
user3 93
user4 67
user5 56
user6 33
user7 22
user8 6
user9 2
user10 0

my script works, but has a syntax error Smilie

the following statements contain the syntax error...believe it's the awk line:

awk '{print $1, $2}' /tmp/idle-ids.lst | while read var1 var2
if [ $var2 -ge 15 ]
echo "$var1 $var2 mins." >> /tmp/idle.msg

is there a better/correct way to redo this awk/while line?

any assistance would be appreciated,
# 2  
Old 01-10-2008
You have a syntax error because of the 2,390 value which is not an integer.
You can change your awk command by using cat, of writing a full-awk script.
# 3  
Old 01-10-2008
Here is a simpler way:

awk '$2 >= 15 { printf("%s %d mins\n", $1, $2) }' /tmp/idle-ids.lst > /tmp/idle.msg

# 4  
Old 01-10-2008
You can try this:
cat /tmp/idle-ids.lst | while read var1 var2
var2=$(echo $var2 | cut -d, -f1)
if [ $var2 -ge 15 ]
     echo "$var1 $var2 mins."

user2 97 mins.
user3 93 mins.
user4 67 mins.
user5 56 mins.
user6 33 mins.
user7 22 mins.

# 5  
Old 01-10-2008
thanks guys!!!
syntax free is always a good thing Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

./ Syntax error at line 1 : `<<' is not matched.

function user { sqlplus primeit@$ORACLE_SID/primeit <<EOF select user_name from test; EOF } function gen { genpwdfile dec -in $1 -out $2 echo $1 echo $2 } function reset { sqlplus primeit@$ORACLE_SID/primeit... (7 Replies)
Discussion started by: ripudaman.singh
7 Replies

2. Shell Programming and Scripting

Cannot execute/finish script because of last line syntax error: unexpected end of file/token `done'

first of all I thought the argument DONE is necessary for all scripts that have or begin with do statements which I have on my script, However, I still don't completely understand why I am receiving an error I tried adding another done argument statement but didn't do any good. I appreciate... (3 Replies)
Discussion started by: wolf@=NK
3 Replies

3. Shell Programming and Scripting

Syntax error at line 24: `(' unexpected

Hi, I am getting an wired error.... the script is running fine when i run it manually... but the same when i try to run in nohup mode, i am getting error if Error: syntax error at line 24: `(' unexpected The above if is the 24th line!!! I dont understand the error... (4 Replies)
Discussion started by: Nithz
4 Replies

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

5. Shell Programming and Scripting

Receiving error: ./ang.ksh[35]: 0403-057 Syntax error at line 116 : `done' is not expected.

Hi All I am quite new to Unix. Following is a shell script that i have written and getting the subject mentioned error. #!/bin/ksh #------------------------------------------------------------------------- # File: ang_stdnld.ksh # # Desc: UNIX shell script to extract Store information.... (3 Replies)
Discussion started by: amitsinha
3 Replies

6. Shell Programming and Scripting

Makefile: syntax error at line 1

I am able to 'Make' some of projects's modules using GNU's make except one where it throws me the following error gmake -f Makefile /bin/sh: syntax error at line 1: `if' unexpected gmake: *** Error 2 I am sure it has nothing to do with the Makefile as there is no 'if' in the first... (1 Reply)
Discussion started by: sudsa
1 Replies

7. Shell Programming and Scripting

ERROR: ./[18]: Syntax error at line 28 : `else' is not expected.

Help please! :confused: I have the following error with the following file and the emails are not arriving to the email, any idea please? ERROR: ./ Syntax error at line 28 : `else' is not expected. FECHA=`date +%d%m%y%H%M`... (2 Replies)
Discussion started by: villenan
2 Replies

8. Shell Programming and Scripting

Urgent: syntax error at line 72: `PROGRESS=$' unexpected

I have written a shell script to Automatically FTP a file. The script runs fine when doing it manually but when I schedule it using a crontab it gives me an error. . . . echo "-----------------Starting File FTP---------------------" >> $PROS_LOAD_LOG echo "open X.XX.XX.XXX" >>... (13 Replies)
Discussion started by: tanhajoy
13 Replies

9. Shell Programming and Scripting

Help on shell script : syntax error at line 62: `end of file' unexpected

Hi All, I have written a korn script (code pasted below). It is giving the error while debugging " syntax error at line 62: `end of file' unexpected". I have re-written the whole code in VI and explored all help related to this error on this Unix forum and tried it. Somehow, I could... (7 Replies)
Discussion started by: schandrakar1
7 Replies

10. Solaris

./runInstaller : syntax error at line 2

Hi all, I've a problem with oracle10.1.0.2 installation on Solaris 10 (I already know this is possible) but when I run "./runInstaller" command from CD I read "syntax error at line 2" followed by several lines (ex. \200\201\203\206...ect). Can you help me please? It is very urgent! (19 Replies)
Discussion started by: Sunb3
19 Replies
Login or Register to Ask a Question