Find the answer to your Linux question:
Results 1 to 4 of 4
hi all, i know i am doing it wrong. I need to output whatever that i am doing in my sftp to a log. how do i do it ? ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2009
    Posts
    10

    how do i output sftp result to a file without scripting ?


    hi all,

    i know i am doing it wrong.
    I need to output whatever that i am doing in my sftp to a log. how do i do it ?

    --------------------------

    I cannot see the commands i inputted, nor the file not found etc..

    what is the correct way to do it ?

    Regards,
    Noob

  2. #2
    Just Joined!
    Join Date
    Dec 2009
    Posts
    10
    here what i done below :

    [tomcat@AIS_WEB 201109]$ sftp login@host > test.log
    Connecting to host...
    Password:
    put abc.txt
    File "abc.txt" not found.
    exit
    [tomcat@AIS_WEB 201109]$ cat test.log
    sftp> sftp>
    [tomcat@AIS_WEB 201109]$

  3. #3
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    My first instinct is to use Perl and the Net::SFTP module.

    But if you don't want the Perl learning-curve (if you don't already know it), then I'd suggest running the sftp job in screen and using screen's built-in logging facility to capture the SFTP output.

    You can call screen to run a job in detached mode - good for scripting ftp jobs.

    Read the screen man page for details.


    Or you could always set up SSH keys (to avoid having to use password prompts), and you could run your sftp jobs as scp calls, all non-interactively - easy to log the output of that.

  4. #4
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    sftp user@host | tee logfile

    maybe?
    linux user # 503963

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •