I try to compare the day and month of someones birthday with the day and month of today, so my little bash script can send a mail to the person that has its birthday that day.
The first line of the file birthdays looks like this:
firstname,lastname,01/01/1990,....
The variable birthday's value is: 01/01
The variable today's value is: 06/08
Yet when i compare them in the if statement you see below, he still executes the commands in the if-block as if the two values were the same.
I tried to change my if statement in a million ways but my output always is "Happy birthday".
Can someone try to explain why this if statement doesnt work?
---------- Post updated at 01:36 PM ---------- Previous update was at 01:35 PM ----------
You are right, doc.arne. One '=' is enough. In fact, some borne shells don't work with two.
But you need spaces around the equal sign in a comparison.
Also, I don't think you want the g flag at the end of the sed expression, in case there happen to be two dates on the line. Although I'm not sure what would happen since you are only printing \1.
Test (=[) is builtin command = not bracket. Usually two mistakes using test command:
variable is empty => no argument => error
no argument separator between arguments - it's commandline, not programlanguage testing with brackets.
Solution: make always string = string length 0 is something = good argument and remember argument delimeters. Ex. in this case test command need 4 arguments: value operator value ]
If you use test command using test (not [ ), then you don't need last argument ].
Yes little funny, but command is exactly the same.
Generic solution for shells (sh, bsh, ksh, bash, zsh, ...): more testing
---------- Post updated at 07:27 PM ---------- Previous update was at 07:23 PM ----------
There are also some other test commands, [[ and ((. Syntax are little different as [ / test.
Hi,
I'm attempting to create case statement in a ksh script that does the following:
Run a uname command against the box and use that value for $HOSTNAME object. Then, if hostname has AIX in it, then use the lsldap command to try to bind, then print $HOSTNAME:yes or $HOSTNAME:no, depending on... (7 Replies)
I am setting up a system as an ADSL gateway. ADSL is working fine. PF is not forwarding for some reason.
# ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33196
priority: 0
groups: lo
inet6... (0 Replies)
What I have here is a pretty textbook recursive function. Its purpose right now is simply to display all folders that don't contain folders.
It works fine in all instances I can think of... except one. If there is a folder with a space in its name, the thing goes Kablooie.
AFAIK the problem comes... (5 Replies)
I am aware this question has been answered time and again. I feel I have tried everything I have seen on the net and really need help to get this working.
Same old story. Shell script, working from command but not from cron. I need my script to take values from a .properties file. Tried... (2 Replies)
Hello All
I have a set of files, each one containing some lines that follows that regex:
regex='disabled\,.*\,\".*\"'and here is what file says about each files:
file <random file>
<random file> ASCII text, with CRLF line terminatorsSo, as an example, here is what a file ("Daffy Duck - The... (3 Replies)
I'm trying to set up a secure and trusted connection between 2 boxes running solaris using ssh2.
I've run ssh-keygen2 on the local box and on the remote box, created the identification file ( IdKey id_dsa_2048_a ) on the local machine and copied across the public key file from the local to... (5 Replies)
I'm very new to UNIX (I just started working with Terminal 2 days ago) and I don't know the system very well.
I'm having trouble whenever I am asked for a password. I simply... can't type. I press keys on the keyboard but no characters appear on the screen. For example, when I log onto... (5 Replies)
Hello
I created an application in c language for HP-UX operative system,and it runs on a 32 bits PARISC processor. My problem is that I have to run this same application but now in a 64 bits Parisc processor. But I am not able to compile the application with the 64 bit server, and I only could use... (1 Reply)
Hi Guys,
I am trying to compare using if, but keep getting some strange results.
if ; then
keeps creating the file 1
if ; then
does not work at all
if ; then
does not work
if ; then
does not work
if ; then
does not work eihter.
I am using a ksh, on Solaris (9 Replies)
i keep getting the following error with the code segment below when i try to compile the program.
The code is from 'defs.h'
parse error before '('
parse error before ')'
stray '\' in program
this is the code segment and the error is on the second line of the segment
#define... (1 Reply)