summaryrefslogtreecommitdiff
path: root/rhimport-dn
diff options
context:
space:
mode:
Diffstat (limited to 'rhimport-dn')
-rwxr-xr-xrhimport-dn33
1 files changed, 22 insertions, 11 deletions
diff --git a/rhimport-dn b/rhimport-dn
index c017d26..fcfa7e9 100755
--- a/rhimport-dn
+++ b/rhimport-dn
@@ -29,6 +29,8 @@ use XML::Feed::Entry;
use XML::Feed::Content;
use XML::Feed::Enclosure;
use File::Fetch;
+use IO::Handle;
+use IPC::Open3;
use lib '/usr/local/share/rhimport/';
use rhimport;
@@ -39,8 +41,7 @@ my $DBPW = "lldriven";
my $DB = "rivendell";
my $RSS_URL = "http://www.democracynow.org/podcast.xml";
-my $PV_SCRIPT = "/usr/bin/ssh";
-my @PV_SCRIPT_ARGS = ('root@intranet', 'addnote', '111');
+my @PV_SCRIPT = ('/usr/bin/ssh', 'root@intranet', 'addnote', '111');
my $user = `/usr/bin/id -un`;
$user =~ s/\n//;
@@ -95,16 +96,24 @@ for my $entry ($feed->entries) {
print "ok\n";
print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n";
-
- push(@PV_SCRIPT_ARGS, sprintf("%04d-%02d-%02d", $today[0], $today[1], $today[2]));
- push(@PV_SCRIPT_ARGS, $sum_title);
- push(@PV_SCRIPT_ARGS, $sum_text);
- system($PV_SCRIPT, @PV_SCRIPT_ARGS);
- if($? eq 0) {
- print "PV: note added successfully";
- }
- else {
+
+ push(@PV_SCRIPT, sprintf("%04d-%02d-%02d", $today[0], $today[1], $today[2]));
+ my ($reader, $writer, $error ) = ( new IO::Handle, new IO::Handle, new IO::Handle );
+ $writer->autoflush(1);
+ local $SIG{CHLD} = 'DEFAULT';
+ my $pid = open3($writer, $reader, $error, @PV_SCRIPT);
+ print $writer $sum_title . "\n" . $sum_text;
+ waitpid $pid, 0;
+ my $out = join('', <$reader>);
+ my $errstr = "";
+ if ( $? >> 8 ) {
+ $errstr = join('', <$error>);
print "PV: adding note failed";
+ print "STDERR:\n" . $errstr . "\n\n";
+ print "STDOUT:\n" . $out . "\n\n";
+ } else {
+ print "PV: note added successfully";
+ print $out . "\n";
}
}
print "\n";
@@ -114,6 +123,8 @@ for my $entry ($feed->entries) {
(-e "$file") or die "file '$file' not found - donwload error?\n";
print "will import $file to dropbox $dropbox (cart=$to_cart)\n\n";
+exit 0
+
my $error_cb = sub {
my ($text) = @_;