?
Solved

Script dosent work ?

Posted on 2008-11-07
12
Medium Priority
?
283 Views
Last Modified: 2012-05-05
Hi!

The given source script give me this error message:
Illegal variable name.

What is wrong with this script ?

Please help asap.


if [ $(date +%A) == "Friday" ]; then
        if [ -f backupfile ]; then
            cp backupfile /BACKUPFRIDAY/backupfile-`date +"%Y%m%d"`; 
        else 
            echo "friday backup file missing" | mail yourmail@ddress -s "missing backup" -; 
        fi;
    fi;

Open in new window

0
Comment
Question by:team2005
12 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 22902874
try

if [ $(date +%A) == "Friday" ]; then
        if [ -f backupfile ]; then
            cp backupfile  /BACKUPFRIDAY/backupfile-`date +"%Y%m%d"`
        else
            echo "friday backup file missing" | mail yourmail@ddress -s "missing backup"
        fi;
    fi;

if you still have problem run the script as

sh -x scriptname

and post output
0
 
LVL 2

Author Comment

by:team2005
ID: 22902905
Hi!

Still dosent work, but it give this output:

Line 24 : [Friday==Friday] : command not found

0
 
LVL 40

Accepted Solution

by:
omarfarid earned 1600 total points
ID: 22902920

if [ $(date +%A) == "Friday" ]; then

It seams that you are not leaving space before and after ==

you may also try using = rather than ==
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 2

Author Comment

by:team2005
ID: 22902933
Hi"

Still dosent work ?

Tor
0
 
LVL 48

Expert Comment

by:Tintin
ID: 22902940
Run the script as

sh -x scriptname

and post the output.
0
 
LVL 35

Expert Comment

by:torimar
ID: 22902955
Is the script set to use the bash shell?

#!bin/bash
0
 
LVL 2

Author Comment

by:team2005
ID: 22902965
Hi!

Yes, its set to use the bash shell.

Tor
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 22902970
can you post the output of

sh -x scriptname

as requested before?
0
 
LVL 2

Author Comment

by:team2005
ID: 22902983
Hi!

Have give you that aoutput:

Line 24 : [Friday==Friday] : command not found

Tor
0
 
LVL 5

Assisted Solution

by:zmo
zmo earned 400 total points
ID: 22902986
hi, the code below works fine for me...
I just changed '==' to '=' like omarfarid suggested.

That's fun, I think I've already seen this code somewhere :p
#!/bin/sh
 
if [ $(date +%A) = "Friday" ]; then
        if [ -f backupfile ]; then
            cp backupfile /BACKUPFRIDAY/backupfile-`date +"%Y%m%d"`; 
        else 
            echo "friday backup file missing" | mail yourmail@ddress -s "missing backup" -; 
        fi;
fi;

Open in new window

0
 
LVL 40

Expert Comment

by:omarfarid
ID: 22902992
here it shows that it is space problem. did you try to put space before and after the == and [ ]
0
 
LVL 2

Author Comment

by:team2005
ID: 22903025
Hi!!

Tryed zmo code, and works now :)

Split the points then :)

Thanks for help.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month17 days, 13 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question