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
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 fartOS: AIXCPU/Ram: P4 / 255Model/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 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: