Bash Script error?


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 8  
Quote:
Originally Posted by vgersh99
Code:
ENDDATE=`date +%d/%m/%Y`

Like so?

Code:
    echo no date provided, defaulting to today $d/$m/$y
    ENDDATE=`date +%d/%m/%Y`

JayC89
# 9  
Quote:
Originally Posted by JayC89
Like so?

Code:
    echo no date provided, defaulting to today $d/$m/$y
    ENDDATE=`date +%d/%m/%Y`

that's right
# 10  
Thanks for the reply. Can you tell me how I can apply the date to the end of specific scripts within this one?

E.G I need first-file.sh and thrid-file.sh to run as

Code:
./first-file.sh 04/10/2007
./third-file.sh 04/10/2007

But within the new script

Thanks again
Jamie
JayC89
# 11  
Code:
#!/bin/sh
    ENDDATE=date +%d/%m/%Y`
 
fi
#
# Begin Scripts
#
for d in  /export/home/siward/staff/pasit/jamiecr/scripts/first-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/second-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/third-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/fourth-file.sh
do
    .....................
    .....................
    .....................
    "${d}" "${ENDDATE}"
    .....................
    .....................
    .....................

done

# 12  
Quote:
Originally Posted by vgersh99
Code:
#!/bin/sh
    ENDDATE=date +%d/%m/%Y`
 
fi
#
# Begin Scripts
#
for d in  /export/home/siward/staff/pasit/jamiecr/scripts/first-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/second-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/third-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/fourth-file.sh
do
    .....................
    .....................
    .....................
    "${d}" "${ENDDATE}"
    .....................
    .....................
    .....................

done

Thanks vgersh! Will this not effect all of the scripts?
JayC89
# 13  
Quote:
Originally Posted by JayC89
Thanks vgersh! Will this not effect all of the scripts?
It the other scripts ignore the command line arguments then all will be well, if not you can use a case statement

Code:
case `basename $d` in
    first-file.sh | third-file.sh )
             "${d}" "${ENDDATE}"
             ;;
    * )
             "${d}"
            ;;
esac

# 14  
Looking something a little bit like;

Code:
#
# Begin Scripts
#
for d in  /export/home/siward/staff/pasit/jamiecr/scripts/first-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/second-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/third-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/fourth-file.sh
#
# Date dependant scripts
#
case `basename $d` in
    first-file.sh | thrid-file.sh )
             "${d}" "${ENDDATE}"
             ;;
    * )
             "${d}"
            ;;
esac
#
# Error Fail Safe
#

Thanks for your help guys, appreciated!

Last edited by JayC89; 10-04-2007 at 06:48 PM..
JayC89
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #975
Difficulty: Easy
In July 2009, Alan Cox quit his Linux kernel development role as the TTY layer maintainer after disagreement with Linus Torvalds about who should pay for beers during a trip to Amsterdam.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Shell Programming and Scripting

Error while sudo to instance via bash script

Team , I am trying to sudo to instnace using a shell script .In out put i am getting this error for every line ...I am running this script as root .. sudo su - userid -i db2 "command " Error /etc/profile: shopt: not found how can we overcome this error ? Can someone help on... (1 Reply)
Discussion started by: rocking77
1 Replies

3. Shell Programming and Scripting

How to ignore error in command in bash script?

Hello, i have bash script where im cycling some command for different lines in external file. example: while read domain;do nslookupout=$(nslookup -type=ns $domain) || true another commands done < filenamewithdomains i added: || true after the command in belief it will just skip... (6 Replies)
Discussion started by: postcd
6 Replies

4. Shell Programming and Scripting

Getting error on for loop - bash script

Hi, I am working on bash script after a long time. I am getting error near done statement while running a for loop snippet. The error says "Syntax error near unexpcted token 'done'" please suggest what could be wrong. here is the snippet elements=${#option_arr} //an array of values... (1 Reply)
Discussion started by: arundhati_s
1 Replies

5. Shell Programming and Scripting

Bash script error problem

Im in a intro to unix class and we have to create a a basic program to look up an argument in a large file. when no argument is given he wants us to produce a error messgae, well this works but it also produces another error message because my variable now equals nothing. #! /bin/bash ... (3 Replies)
Discussion started by: laxkrzy
3 Replies

6. Shell Programming and Scripting

FTP script error in BASH

Hi All, I have a script which is supposed to connect to Windows machine and FTP a file into LINUX. Script is like below #!/usr/bin/sh ParamterFle=${1} //grepping all parameters BossFtpLog=${2} // assigning log file ftp -i -n host_name << EOF user1 password1 cd /drive1/drive2 get... (6 Replies)
Discussion started by: Raamc
6 Replies

7. Shell Programming and Scripting

Strange error in bash script

Howdy all, I have a scritp that does a sqldump. But for some goofy reason, a certain part of it behaves uber strange. It does a daily dump of my sql, according to parameters I enter in hardcode. The script is: #!/bin/bash APP_NAME="app_com_site" wikiname="wiki_com_site" ... (8 Replies)
Discussion started by: saariko
8 Replies

8. Shell Programming and Scripting

BASH Script syntax error

I'm trying to write a simple script that takes all the .tar.gz files in a directory and verifies them by using the gzip -tv command: for zip in *.tar.gz do gzip -tv $zip if ; then #Check return code from tar echo "File ${zip} verified OK." exit... (4 Replies)
Discussion started by: kelldan
4 Replies

9. Shell Programming and Scripting

Help in error seen in the Bash script

Hi, I am currently encounter an error of:- ./max.bash: line 45: then max=0 else max=$maximum It seems that it does not allow max to assigned with floating numbers. Please help. Thanks. (2 Replies)
Discussion started by: ahjiefreak
2 Replies

10. Shell Programming and Scripting

error in bash script 'if' loop

SEND_MESSAGE=test echo $SEND_MESSAGE if then echo `date` > update_dt_ccaps.lst echo "The file transfer failed" >> update_dt_ccaps.lst SEND_MESSAGE=false fi The above code is showing error in bash shell as : ./test: line 5: [: test: integer expression expected ... (2 Replies)
Discussion started by: DILEEP410
2 Replies

Featured Tech Videos