Skip to content

Instantly share code, notes, and snippets.

@vrillusions
Created January 9, 2012 16:27
Show Gist options
  • Save vrillusions/1583683 to your computer and use it in GitHub Desktop.
Save vrillusions/1583683 to your computer and use it in GitHub Desktop.
Generate a list of commands with a date parameter

At one point at work I needed to run a script several times. As a quick and dirty hack I made this python file that just gives me a list. I then ran it several times changing the month. It's quick, it's messy, but it worked.

#!/bin/bash -e
SCRIPT="php whatever/its/called.php"
# use the script.py file to get the output for this
$SCRIPT --date=2012-01-31
$SCRIPT --date=2012-01-30
$SCRIPT --date=2012-01-29
$SCRIPT --date=2012-01-28
$SCRIPT --date=2012-01-27
$SCRIPT --date=2012-01-26
$SCRIPT --date=2012-01-25
$SCRIPT --date=2012-01-24
$SCRIPT --date=2012-01-23
$SCRIPT --date=2012-01-22
$SCRIPT --date=2012-01-21
$SCRIPT --date=2012-01-20
$SCRIPT --date=2012-01-19
$SCRIPT --date=2012-01-18
$SCRIPT --date=2012-01-17
$SCRIPT --date=2012-01-16
$SCRIPT --date=2012-01-15
$SCRIPT --date=2012-01-14
$SCRIPT --date=2012-01-13
$SCRIPT --date=2012-01-12
$SCRIPT --date=2012-01-11
$SCRIPT --date=2012-01-10
$SCRIPT --date=2012-01-09
$SCRIPT --date=2012-01-08
$SCRIPT --date=2012-01-07
$SCRIPT --date=2012-01-06
$SCRIPT --date=2012-01-05
$SCRIPT --date=2012-01-04
$SCRIPT --date=2012-01-03
$SCRIPT --date=2012-01-02
$SCRIPT --date=2012-01-01
exit 0
#!/usr/bin/env python
from datetime import date
# none of this is used
## number of days to go back
#days = 30
#
#today = date.today().strftime('%j')
#print today
for x in reversed(range(1,32)):
print '$SCRIPT --date=' + date(2012,1,x).isoformat()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment