Control a non-perl image viewer from perl script
From: Harry Putnam (reader_at_newsguy.com)
Date: 10/30/03
- Next message: Chris McMahon: "RE: finding out my IP address.."
- Previous message: Kevin Old: "Re: Range of dates help needed"
- Next in thread: Zentara: "Re: Control a non-perl image viewer from perl script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: beginners@perl.org Date: Thu, 30 Oct 2003 09:27:49 -0600
Below is a (non-finished) script that trys to run a linux viewer
called eog (eye of gnome) in a script that will eventually allow me to
power thru long lists of image files and rename them as I go.
The idea was a cmdline tool that would pop up a view of each image
then query user for new name. Kill that process and move on to next
item in list.
I couldn't think of any better way than to query `ps' for the pid and
run `kill' on it. However even that isn't working.
But I wondered if there is a better way of doing this that is still
fairly basic?
#!/usr/local/bin/perl -w
$question = "New name please => ";
$ext=shift;
$ls_proc = "ls *.$ext";
open(LS_PROC," $ls_proc|");
while(<LS_PROC>){
chomp;
push @ls_array,$_;
}
for(@ls_array){
$pic = $_;
system("eog $pic &");
print $question;
chomp ($newname = <STDIN>);
print "<$newname>\n";
qx(cp -a $pic "$newname.$ext");
## rename $_ "$newname.$ext";
open(PS_PROC,"ps wwaux|");
while(<PS_PROC>){
chomp;
if($_ =~ /^$ENV{LOGNAME}.*eog.*\.jpg$/){
my $line = $_;
print "hpdb \$line = $line\n";
<STDIN>;
$pid = (split(/\s+/,$line))[1];
print "hpdb \$pid = $pid\n";
<STDIN>;
print "kill -15 on $pid?\n";
$ans = <STDIN>;
if ($ans eq "y"){
print "Killing -15 on pid <$pid>\n";
qx(kill -15 $pid);
}
}
}
close(PS_PROC);
}
close(LS_PROC);
- Next message: Chris McMahon: "RE: finding out my IP address.."
- Previous message: Kevin Old: "Re: Range of dates help needed"
- Next in thread: Zentara: "Re: Control a non-perl image viewer from perl script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|