Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Script help, Im having a brain fart

Original Message
Name: aka
Date: May 15, 2007 at 11:52:09 Pacific
Subject: Script help, Im having a brain fart
OS: AIX
CPU/Ram: P4 / 255
Model/Manufacturer: Custom
Comment:
Hi all,

This is a simple script for some other I’m doing, but before change example1 I wanted to test with an example 2.

The code must be work this way.

./test James
Good morning James--- END

./test nojames
Usage: ./test James or james.

Code I have done, but Im having a hard brain fart, is this.

#!/bin/bash
name=$1

if ($name != “James” -o $name != “james” ); then
echo "usage: $0 James or james"
exit 1
else

echo "Good morning $name"

fi


Don´t freak out until you know the facts...Relax...!


Report Offensive Message For Removal


Response Number 1
Name: Guy
Date: May 15, 2007 at 17:57:20 Pacific
Subject: Script help, Im having a brain fart
Reply: (edit)
Try [] instead of ().

Try -a instead of -o.



Report Offensive Follow Up For Removal

Response Number 2
Name: aka
Date: May 15, 2007 at 18:02:09 Pacific
Subject: Script help, Im having a brain fart
Reply: (edit)

I already did that before, but didnt help, some other clue ?

Thanks.

Don´t freak out until you know the facts...Relax...!


Report Offensive Follow Up For Removal

Response Number 3
Name: Guy
Date: May 15, 2007 at 18:11:04 Pacific
Subject: Script help, Im having a brain fart
Reply: (edit)
Also make sure that:

there is a space/blank right after [

there is a space/blank right before ]

What happens?


Report Offensive Follow Up For Removal

Response Number 4
Name: aka
Date: May 15, 2007 at 18:19:03 Pacific
Subject: Script help, Im having a brain fart
Reply: (edit)
Great, it worked.

But, what does -a do ?... why didnt it work with -o, I had made some other codes with -o and it work ?..

Thanks Guy...

Don´t freak out until you know the facts...Relax...!


Report Offensive Follow Up For Removal

Response Number 5
Name: nails
Date: May 16, 2007 at 09:31:35 Pacific
Subject: Script help, Im having a brain fart
Reply: (edit)
Are you familiar with boolean algebra? In shell the -a is the "and" and the -o is "or".

($name != “James” -o $name != “james”

The above reads if name is NOT James or name is NOT james, it is true. If you stop to think about it, with an "or" either [Jj]ames is still true.

Check out this link:
http://en.wikipedia.org/wiki/Boolea...

click on "AND" for further info.

If you stil have trouble, try something like this:

# untested
if [ $name = "James" -o $name = "james" ]
then
:
else
echo "name is not [Jj]ames"
fi


Report Offensive Follow Up For Removal


Response Number 6
Name: aka
Date: May 16, 2007 at 09:35:32 Pacific
Subject: Script help, Im having a brain fart
Reply: (edit)

thanks Nails.

I already got some torrents for O'Reilly bash scripting.

and found some interesting links, including yours, but it will always be helpfull to post here ;)

Don´t freak out until you know the facts...Relax...!


Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Script help, Im having a brain fart

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




how to setup call of duty to joytok

WindowsME / HotMail Problem

Corrupt memory

Convert fat32 to Ntfs

Best WinMo phone of 2008


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC