mardi 26 septembre 2017

Execute Python script conditionally in Bash OSX

New to Bash, apologies in advance.


Set-up

I have a starting date s, a period p and an end date end such that end = s + p.

If todays date now is before or equal to the end, I want to execute a command.

The code works fine if the command to be executed is echo ok.


Code

In stead of echo ok, I want the Bash to execute two .py scripts after each other.

cd /mypath
PATH=$PATH:/usr/local/bin
export PATH

s='20170915’
p='30'
end=$( date -j -v+"$p"d -f "%Y%m%d" "$s" +"%s" )
now=$( date +"%s" )

if (( now <= end )); then    
    python script1.py;python script2.py;
fi

This does not work. How do I get the Bash to execute the two .py scripts?

I checked this question, but this does not seem to work.

Aucun commentaire:

Enregistrer un commentaire