Control a non-perl image viewer from perl script

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default Control a non-perl image viewer from perl script

    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);

    Harry Putnam Guest

  2. Similar Questions and Discussions

    1. Image Viewer Control
      Hello All, Could anybody please give me ideas on building a Image viewer control regards, Kuldeep
    2. RFC on first perl script
      Hi all well im trying at lerning this perl stuff.. reading from the "learning perl" oreilly book and a few other places, but also using perl a...
    3. ASP --> PERL SCRIPT
      try using $ENV{THIS_SCRIPT}
    4. ASP --> PERL SCRIPT HELP>>PLEASE>>
      Hello..I was browsing thru the newsgroups ...and was wondering if anyone here can be of assistance to me....as I am very very new to PERL..and have...
    5. Execute shell script from a perl script
      Hi, How can I executed a Unix shell script from a Perl script. The shell script is a dump of a oracle table to a file. The perl script is for...
  3. #2

    Default Re: Control a non-perl image viewer from perl script

    zentara <zentara@highstream.net> writes:
    > You could also check out: [url]http://herrmanns-stern.de/[/url]
    > for a couple of image viewer utilities written in perltk.
    >
    > Here is some code which will give you a good outline for
    > forking and execing which will let you kill the stored pid.
    > Working your image viewer in should be pretty simple.
    Many thanks, the code is right on the mark and the app you mentioned,
    well it looks like Martin H. wanted to do the same thing I did and
    lots more... only he knew how to do something about it..

    Thanks

    Harry Putnam Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139