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

Hi there,

I am using Net::SFTP to upload some files to a sftp site, and when I run the script from command line, all goes smoothly.

However, I want to be able to kick off the script from a php webpage, and when I call my script from php, it is silently failing. I believe I have narrowed it down to something with the underlying SSH is not connecting properly due to there being no terminal.

Currently, I'm trying to disable pseudo-tty and set "BatchMode yes" as follows:

$ftp = Net::SFTP->new($ftpIP, user => $ftpUsername, password => $ftpPa +ss, ssh_args => [protocol => '2,1', use_pty => 0, options => ["BatchM +ode yes"]]) or die($@);

Has anyone ran into this problem before?

Replies are listed 'Best First'.
Re: Net::SFTP no terminal
by salva (Canon) on May 24, 2011 at 07:43 UTC
    I believe I have narrowed it down to something with the underlying SSH is not connecting properly due to there being no terminal.

    Why do you thing so? have you run it with debugging enabled? if so, what output did you get?

    AFAIK, the Net::SSH::Perl SSH implementation used by Net::SFTP, in its way, uses "BatchMode" by default.

    You can also try using Net::SFTP::Foreign that uses any binary SSH client installed on your machine for the SSH layer.