[ale] script
Cor van Dijk
cor.angela at mindspring.com
Tue May 22 14:17:10 EDT 2001
Paul Kinsley wrote:
> Cor van Dijk wrote:
>
> > Greetings,
> > I am trying to write a script which will feed a single line of output of
> > "locate" into a simple imageviewer like
> > "gqview" or "kview" (redhat6.2). I tried both shell scripting and Perl,
> > so far with little succes. Obvious things
> > like piping wont work. Perl seems to categorize this problem under
> > "interacting with strangers". Also, there might be image viewers which
> > will accept a command line from a file, but I haven't found any.
> > Any ideas welcome.
> >
> > Cor van Dijk
> >
> >
> > --
> > To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.
> >
> >
>
> Try locate filename | xargs fileviewer
> --
> Paul Kinsley
> Senior Systems Engineer
> paul at motionrealityinc.com
Paul,
That line worked great! Thank you very much!.
Meanwhile I managed to cook up something with a lot of bells and whistles
(of course just after I posted a cry for help!)
It is not nearly as elegant as your line but it does some other things as well:
--------------------snip------------------------------------
#!/usr/bin/perl
# This script locates a file and then puts that file in an imageviewer
# if it is a jpeg file.
# Usage: peek <filename.jpg>
$x = $ARGV[0];
if ($x eq help || $x eq "" ) { print "Usage: peek <filename>\n"; exit; }
system ("locate $x > peeklist");
open(FILE, peeklist) or die "Can't open $!\n";
while (<FILE>) {
$output .= $_;
if ( $_ =~ /.jpg\b/ ) {
print "Now showing: $_\n";
system ("display $_"); # Works with gqview, ee, kview, display
(ImageMagick), gimp.
} else {
print "Not a jpeg file: $_\n";
}
print "Continue? ";
$yesno = <STDIN>;
chomp $yesno;
if ($yesno eq "no" ) {
close (FILE);
print "Total: \n$output\n";
system ("cat peeklist >> donelist");
exit;
}
}
close (FILE);
print "Total: \n$output\n";
system ("cat peeklist >> donelist");
--------------------snip-------------------------------------
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.
More information about the Ale
mailing list