SPUG: backticks, system, and ImageMagick
Tim Maher
tim at consultix-inc.com
Sun Mar 17 18:18:19 CST 2002
(Forwarded after spam-laundering)
-Tim
I suspected that STDERR might be the culprit, but then
as you say, I should still be seeing the output in the
dos shell.
Bob Brockhausen wrote:
> What I did was to put the entire command &
> the file redirect inside the call to "system"
> and return code is assigned to local scalar.
> If scalar > 0 then it was good else not good...
>
> $var = sysetm("/usr/sbin/ping $host 128 10
> >/dev/null");
> if ($ var != 0) { #enter more processing to do since
> I can't ping $host
> hopefully this will work for you If I understand
> your problem....
However what I need to do is capture the output from
the command. Specifically, I am trying to run:
identify picture.jpg
which returns:
picture.jpg JPEG 312x135 DirectClass 8-bit 17235b 0.1u
0:01
This gives me the geometry of the graphic so that I
can make decisions on what to do with it.
I can't figure out if the output is going to STDERR or
if nothing is even running.
David Corcoran wrote:
> When in windoze I usually do something like this:
>
> open CMD,"program |" or die;
>
> while (<CMD>) {
> print;
> }
however, this shows the same symptoms, mogrify works,
identify doesn't
.
Colin Meyer suggested trying the PerlMagick module.
I am trying to get it built but it requires nmake,
which I have as part of Visual Studio but during the
make, it complains about missing .dlls which I am
still trying to track down.
Keep those ideas coming. I am running win98 btw.
Rich
--- Matt Tucker <tuck at whistlingfish.net> wrote:
> -- Richard Wood <wildwood_players at yahoo.com> spake
> thusly:
>
> > I am having a problem with backticks and I am
> looking
> > for new ideas on what it could be.
>
> > When I write a very simple script such as:
> >
> > perl -e "print `mogrify`;"
> >
> > I get the usage only if I use mogrify, or convert.
>
> > If I try identify, composite, or montage, I get
> > nothing.
>
> > Could some of the commands be writing to something
> > other than STDOUT? like STDERR?
>
> Yes. Backticks fail to capture STDERR, and many
> programs write their
> usage to that. However, you should still be seeing
> the output, since
> the backticks aren't capturing it.
>
> On unix I'd say do '2>&1', but obviously that's not
> a choice without
> installing cygwin. The other option is to use
> something like
> IPC::Open3. As I recall there's an OO interface to
> that functionality
> that works rather nicely, but I can't remember what
> it's called.
>
> ATTACHMENT part 2 application/pgp-signature
=====
Richard O. Wood
Wildwood IT Consultants, Inc.
wildwood_players at yahoo.com
425.941.9437
__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com
----- End forwarded message -----
--
*==============================================================================*
| Dr. Tim Maher, CEO, Consultix (206) 781-UNIX/8649; ask for FAX# |
| tim at consultix-inc.com www.consultix-inc.com www.softwareprofessor.com |
| FEB: Perl; APR: Shell; Int. & OO Perl; Perl DataBase; JUNE: Basic UNIX, Perl |
*------------------------------------------------------------------------------*
| NEW Seminar Series! "DAMIAN CONWAY's Adv. Perl Workshop"; Seattle, 7/15-18 |
| Adv. OOP * Adv. Module Implementation Techniques * Programming in Perl 6 |
*==============================================================================*
----- End forwarded message -----
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list