apfritts has asked for the wisdom of the Perl Monks concerning the following question:

Hi!

I need to have a cron job SSH to an array of machines and execute scripts. Unfortunately, these scripts need a tty or ptty in order to operate correctly.

When I execute the script (testing) in my terminal, everything works just dandy. When the cron runs the scripts, they fail.

I have tried connecting a standard IO writer using IPC::Open3, but it still doesn't work because that is not a terminal.

I have looked at Term::VT102 (or whatever it is) and I don't think you can connect that to open3 as STDIN.

Has anyone encountered this problem before? Does anyone know of a module that can emulate a terminal that I can connect to STDIN on open3?

Thanks!

A government big enough to give you everything you want, is strong enough to take everything you have. - Thomas Jefferson

Replies are listed 'Best First'.
Re: Emulate a terminal to SSH
by Fletch (Bishop) on Sep 17, 2009 at 17:34 UTC

    Expect and IO::Pty come to mind, as possibly does the -t flag to ssh if the tty needs to be allocated on the remote side.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: Emulate a terminal to SSH
by desemondo (Hermit) on Sep 18, 2009 at 04:41 UTC
Re: Emulate a terminal to SSH
by arden (Curate) on Sep 18, 2009 at 14:21 UTC
    One other thing to keep in mind is that jobs run via cron do not have the full environment set up for them. You have to explicitly define things in the %ENV hash for your script to use them; for example ORACLE variables.
Re: Emulate a terminal to SSH
by flipper (Beadle) on Sep 19, 2009 at 19:06 UTC
    from man ssh:
         -t      Force pseudo-tty allocation.  This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services.  Multiple -t options force tty allocation, even if ssh has no local tty.