#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    238
    Rep Power
    12

    Question System("FTP") question...?


    Hi all,

    How could I save the STDOUT that is displayed after a command line issue of system("FTP ..")?
    I want to be able to capture the screen output of that system call to FTP in a text file.

    Thanks in advance!

    Gary
  2. #2
  3. An Ominous Coward
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2002
    Posts
    4,425
    Rep Power
    0
    Using system() captures the return value of the program that executed (i.e. "did it succeed or fail?"). You want `COMMAND` (those are backticks) which returns the output.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    238
    Rep Power
    12
    Not sure how to use `COMMAND`
    Do the arguments get passed within the backticks?

    Like:
    @ARGS=("FTP", "arg1", "arg2");
    `COMMAND, @ARGS` ?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    238
    Rep Power
    12
    Also,

    apparently the information from the application (FTP here) passed in system() call, can be redirected to a file...which is exactly what I need to do.
    I just don't know how to redirect the info.

    Thanks,
    Gary
    Last edited by rxsid; August 20th, 2002 at 08:17 PM.
  8. #5
  9. An Ominous Coward
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2002
    Posts
    4,425
    Rep Power
    0
    Yea... use backticks. Backticks return the output, so if you say:
    Code:
    print FILE `ftp`;
    The output of the command goes to the open filehandle FILE. Variables interpolate inside backticks, so you can put your parameters inside of them.
    Last edited by Ctb; August 21st, 2002 at 12:15 AM.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    238
    Rep Power
    12
    Thanks ctb!

    Thats exactly what I needed.
    I do appreciate your help.

    Gary

IMN logo majestic logo threadwatch logo seochat tools logo