Thread: How to hide output in a console

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    16

    How to hide output in a console

    I was wondering how I could hide output from a console window. I'm creating a newsupdating script and use:
    Code:
    system ("ftp -s:filename.txt");
    to upload the file, but I want to hide the output of the ftp program.. And only show "Uploaded successfully" when the file has been uploaded..

    I have no idea where to start.. I'm a beginner so, help is very welcome..

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Perhaps use something other than the system command. ShellExecute or CreateProcess might work better for you if you're on Windows.

    Look in the FAQ for running a program from another program. It has other ideas and examples beyond system that might work for you.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Code:
    system ("ftp -s:filename.txt > nul:");
    That will redirect any output to stdout to NUL: which is "nowhere".

    --
    Mats

  4. #4
    Registered User
    Join Date
    Jul 2007
    Posts
    16
    thanks alot!

  5. #5
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    I think popen() would also do the job. I haven't used it much yet, but you could give it a try.

  6. #6
    Registered User
    Join Date
    Aug 2007
    Posts
    85
    or simply try @ before the command. that works in batch files, at least

  7. #7
    Registered User
    Join Date
    Jul 2007
    Posts
    16
    hmm, so I could call a batchfile too.. not that it's very usefull lol. I will try if it works in C++ too.. Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to get the console output
    By outlawbt in forum Windows Programming
    Replies: 2
    Last Post: 03-19-2008, 02:25 PM
  2. redirect console output to a String?
    By TwistedMetal in forum C Programming
    Replies: 10
    Last Post: 02-26-2008, 02:54 PM
  3. Help with Console output
    By JeremyCAFE in forum C++ Programming
    Replies: 4
    Last Post: 12-20-2005, 10:36 AM
  4. Redirecting console output
    By _hannes in forum Windows Programming
    Replies: 3
    Last Post: 11-04-2004, 04:51 AM
  5. How to hide cursor in a Linux/Unix console?
    By Aidman in forum Linux Programming
    Replies: 2
    Last Post: 09-01-2004, 02:25 PM