Created
May 19, 2013 22:01
-
-
Save mintsoft/5609225 to your computer and use it in GitHub Desktop.
Pipe a command into psql within a loop with a heredoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
$svr="localhost"; | |
$dbname="rob"; | |
for $x (1..10) { | |
open(CMD, " | psql -h $svr $dbname"); | |
print CMD <<END; | |
BEGIN TRANSACTION; | |
INSERT INTO insert_log ("when") VALUES(NOW()); | |
INSERT INTO insert_log ("when") VALUES(NOW() + interval '$x day'); | |
COMMIT; | |
END | |
print CMD $heredoc; | |
close(CMD); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment