Hi,

So I have looked for an answer to my issue and, pardon me if this has already been answered, but I have written a script that will use SCP to copy a file to a remote server. This is done in the browser and of course I am getting the error

======================

Error: last line returned was: stdin: is not a tty

======================

Here is my code: =======================

!/usr/local/bin/perl use IO::Pty; use CGI qw(:standard); use CGI; use CGI::Carp qw(fatalsToBrowser set_message); use CGI::Carp; # send errors to the browser, not to the logfile use Net::SCP::Expect; use Term::ProgressBar; #use CGI::ProgressBar qw/:standard/; print "Content-type: text/html\n\n"; print "<HTML>"; #print "<H1>Uploading Your File</H1>\n"; my $ipaddress=param("ipaddress"); my $remotepass=param("remotepass"); my $localfile=param("localfile"); my $remotedir=param("remotedir"); my $remoteport=param("remoteport"); my $user="root"; my $filename="./uploads/"; my $file=$filename . $localfile; my $scpe = Net::SCP::Expect->new(host=>$ipaddress, user=>$user, passwo +rd=>$remotepass, port=>$remoteport, auto_yes=> '1', auto_quote=> '0') +; $scpe->scp($file, $remotedir);

=========================

Now I can transfer the file without any issues from a prompt of course, but am unable to do so from the browser.

What I am trying to do here is to allow people who don't know how to use scp or do not have access to a terminal to scp files to a vps (I have my reasons, it's a long story).

I have added the apache user running the script to the root group and was actually able to transfer a file to a random server, but I have been unsuccessful with any other attempt after that.

I am curious if anyone can offer any insight as to how I can work this out.


In reply to SCP and tty by croddam

Title:
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, details, 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, summary, 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.