can I use this coding


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users can I use this coding
# 1  
Old 02-26-2004
can I use this coding

I apologise because I had pasted this question in the newbies forum first (because i am a bit of a newbie) but thought it might be better suited in here

if i have to sepearate parameters can I use this syntax especially the or part (||) and is this correct

if [ "${CURR_STATUS}" || "${CURR_STATUSTEST}" != "${NEW_STATUS}" ]
# 2  
Old 02-26-2004
why not try it befor you ask if it works?
# 3  
Old 02-27-2004
Optimus cheers for the offhand reply

the code was tried (but as I said Im fairly new and not to clued up on the syntax) so although this particular part of the code may not work it may be due to the syntax rather than than the coding

i.e.

this coding was correct

CURR_STATUS =`cat /export/home/troberts/status_LIVE`

but it took me nearly 8hrs to work out the syntax was wrong.
should have been

CURR_STATUS=`cat /export/home/troberts/status_LIVE`

so the question was not an error on my part, just a general enquiry that I thought may have been answered with a little more understanding
# 4  
Old 02-27-2004
Re: can I use this coding

I'd use double brackets:
Code:
if [[ "${CURR_STATUS}" || "${CURR_STATUSTEST}" != "${NEW_STATUS}" ]]

Besides that, it should work, but I'm not sure what you intend it to do. Basically, the statement will be true if either:

1) CURR_STATUS is anything (other than null), or
2) CURR_STATUSTEST and NEW_STATUS do not match
# 5  
Old 02-27-2004
Cheers OOmbera

The code is used as validation when changing a password in a case statement where there are 2 seperate enviroments to compare

ie case and casetest

Thanx again
# 6  
Old 02-27-2004
Quote:
Originally posted by w33man
Optimus cheers for the offhand reply
...
so the question was not an error on my part, just a general enquiry that I thought may have been answered with a little more understanding
Well I will point out that your question did not exhibit much thoughtfullness on your part. You did not tell us what shell you are using or what result you wanted. Futhermore it was a crosspost which is a violation of our rules. You reap what you sow. I choose to ignore your question other than deleting the duplicate post.

I still don't know what shell you're using, but the syntax that oombera suggests seems to be illegal in ksh. Some quick experiments with bash seem to suggest that it does work there, but on bash, [ and [[ just seem to be the same thing. (On the other hand, many shells will accept your original syntax.)
# 7  
Old 03-02-2004
Quote:
Originally posted by Perderabo
I still don't know what shell you're using, but the syntax that oombera suggests seems to be illegal in ksh.
I usually try code before I post it. I did this time too. For me, it worked in ksh with double brackets, but not with single, so it seemed like a legit suggestion.
Quote:
Originally posted by jimmyriddle
Perderabo,

Thanks for your help and courteous manner in responding to my thread.

Your positive approach to my problem is much appreciated.
That's our Perderabo ... mr. congeniality. Smilie

---------
oh well, what can you say about someone who knows 1000x as much unix as you do..? just deal with it i guess... Smilie

Last edited by oombera; 03-02-2004 at 09:12 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

HTTP coding

My company has an in house instant messaging system (like WhatsApp) where users can communicate with each other. I currently have code to email me certain items from my Sparc machine running SunOS 5.10. I want what I am emailing myself to now instant message me. The team that created the messenger... (5 Replies)
Discussion started by: shorty
5 Replies

2. Windows & DOS: Issues & Discussions

Need help with coding

HI, Can some one guide me how to make changes to the script below so that it can load the history of a program to IT server ? Format of data: YYYYMMDD065959.dsk.log YYYYMMDD235959.dsk.log currently both are loaded together. Need to separate them as above format. Thanks in advance. ... (2 Replies)
Discussion started by: crazydude80
2 Replies

3. Shell Programming and Scripting

Need help with coding

HI, Can some one guide me how to make changes to the script below so that it can load the history of a program to IT server ? Format of data: YYYYMMDD065959.dsk.log YYYYMMDD235959.dsk.log currently both are loaded together. Need to separate them as above format. Thanks in advance. ... (1 Reply)
Discussion started by: crazydude80
1 Replies

4. AIX

need help for coding this logic

contact me on <email address deleted> or <email address deleted> (1 Reply)
Discussion started by: suprithhr
1 Replies

5. UNIX for Dummies Questions & Answers

pro*c coding

Hi All, I am new to pro*C. I have a select statement as select a.ename,a.sal,a.empno from emp where &n=(select count(distinct(b.sal)) from emp b where a.sal<=b.sal for this query I have to write a pro*C program. So can you please send me the complete code. Then I will foloow the same... (1 Reply)
Discussion started by: user71408
1 Replies

6. Shell Programming and Scripting

Coding on my Mac

I would like to start coding on my mac, but I'm getting an error when I attempt to execute my script -bash : testscript: command not found I have verified that the #! line points to the correct directory. If you have some insight it would be greatly appreciated! - D (1 Reply)
Discussion started by: DKNUCKLES
1 Replies
Login or Register to Ask a Question