Problem inside 'if'


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem inside 'if'
# 1  
Old 09-12-2007
Problem inside 'if'

Hi,

I am using a test inside an if loop like below
if [ \($current_min - $timestamp_min\) -le "2" -o \($current_min - $timestamp_min\) -le "2" ]
then
..........do something...

However, when I am running the script by sh -x <script_name>, I am getting an error like test.sh: test: unknown operator -.

Both the variables current_min and timestamp_min are numeric.

Many thanks
# 2  
Old 09-12-2007
You can try this:


if [ `expr $current_min - $timestamp_min` -le 2 -o `expr $current_min - $timestamp_min` -le 2 ]
then
echo "testing"
fi
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem run script inside a gnome-terminal

hi, I would like to ask about using gnome-terminal command, I had a script that will run my VBOX VM in headless and i want to display the output(STDOUT) on the gnome-terminal window. The purpose that i want to display the STDOUT of the script cause i will used it or create a desktop shortcut for... (11 Replies)
Discussion started by: jao_madn
11 Replies

2. Shell Programming and Scripting

Problem using variable inside awk

HI, This is the code I am using: awk -v aaa="connect" 'BEGIN {IGNORECASE} /aaa/,/!/ {print NR}' bb This does not throw any error but it does not work. Pls help Thanks. (4 Replies)
Discussion started by: sudvishw
4 Replies

3. Shell Programming and Scripting

problem in assigning substr to a variable inside awk

Hi All, I have a fixed-width datafile from which i need to extract value/string starting from some position to the specified length in each of the lines. awk '{print substr($0,x,y)}' datafile --- is working fine but awk 'BEGIN{a=0}{a=substr($0,x,y);print $a}' datafile ---is giving... (3 Replies)
Discussion started by: loggedin.ksh
3 Replies

4. UNIX for Dummies Questions & Answers

Problem with Sudo inside a here document

Have a sudo statement inside of a here document. It prompts me for a password, but doesnt wait for me to enter my password. Is there a way I can use the command without sudo or anyway that I can enter the password correctly? Eg : while read remotehost do ssh -t $2@$remotehost ... (0 Replies)
Discussion started by: mnanavati
0 Replies

5. UNIX for Dummies Questions & Answers

problem with character @ inside username to use pop3 with nail

Hi: I am trying to read mails using pop3 protocol with the nail client. I have configurated the following files: .mailrc set NAIL_EXTRA_RC=~/.nailrc .nailrc shortcut myisp pop3://developers@afinformatica.com@mail.afinformatica.com set... (2 Replies)
Discussion started by: chemi
2 Replies

6. Shell Programming and Scripting

Problem using ssh inside script

Hi, When runnin the following script it complte successfully with out any problem #!/bin/sh SERV="crm1" for s in $SERV do export WebLogicSessions=`ssh psoft@$s "cd /software/psoft/scripts ; ./getweblogicsessions.sh crm1 8001 PIA | awk '{print $1}' ` echo "Checking number of... (0 Replies)
Discussion started by: yoavbe
0 Replies

7. UNIX for Dummies Questions & Answers

Problem with executing command inside a cron job

Hi All, I have scheduled a script in cron which writes output to the below file. ....>> /data/Target/wrapper_invoke_ds_job_`date '+%Y%m%d'`.ksh_out 2>&1 But the date command is not getting resolved in the format specified. It just resolves to the following. wrapper_invoke_MQ_ds_job_Tue... (3 Replies)
Discussion started by: pkm_oec
3 Replies

8. Shell Programming and Scripting

Execute command inside while problem

Hi! How can I execute a linux command inside the while cicle?? like: This doesn't work. Should I replace the by '' or "" (3 Replies)
Discussion started by: ruben.rodrigues
3 Replies

9. Shell Programming and Scripting

problem with Variable inside SSH

Hi Friends, i have small issue,... here is my problem............:) i am using two unix box A and B ..using my script i am able to connect from A to B without password(using ssh option like below). A:-> ssh user@B-2.10.32.23 but i declared one variable in A which is something... (5 Replies)
Discussion started by: Shahul
5 Replies

10. UNIX for Dummies Questions & Answers

problem in reading inside a while loop

I am not able to read inside a while though i get the message "inside read" the cursor doesnt prompt from the console cat file | while read ln_new_engine_dirs do echo "inside $ln_new_engine_dirs" if then read nn echo "inside read" fi done Thanks in advance (3 Replies)
Discussion started by: ssuresh1999
3 Replies
Login or Register to Ask a Question