Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hi, Someone asked on the perl.beginners maillist, a question about running gpg thru a script. Well I thought It could be run thru IPC::Open3, but there is a complication. Gpg grabs the tty of the perlscript, preventing IPC from operating.

If you run the script below(modified to edit a suitable name for your system), gpg, grabs the tty. If you enter "trust" followed by Enter, a new menu appears. That is the functionality I'm trying to perform thru the script.

If I print to the IN filehandle, it does nothing. I've noticed that the Crypt::GPG module uses IPC::Run and an undocumented gpg option called "--no-tty", but that aside, I just want to know how to access the STDIN to gpg.

On my system gpg is shown using /dev/pts/5, and I can't seem to be able to print to it. Is it possible thru some sort of fileno magic?

#!/usr/bin/perl use warnings; use strict; use IPC::Open3; use POSIX; my $childpid = open3(\*IN, \*OUT, \*ERR, 'gpg --edit zentara'); #gpg grabs control of the tty here my $tty0 = ttyname(0); #STDIN my $tty1 = ttyname(1); #STDOUT print "$tty0 $tty1\n"; # they are /dev/pts/5 on my machine #how do I print to STDIN of /dev/pts/5 ? print IN "trust\n"; chomp(my $answer = <OUT>); print $answer; if ($answer =~ /Your decision/) { print IN "5\n"; }else { print "decision error $!\n"; exit; }

I'm not really a human, but I play one on earth. flash japh

In reply to Running gpg thru IPC, fileno problem by zentara

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (3)
    As of 2021-03-01 02:00 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found