0

I have a script that connects to an FTP server and while doing so prints out a load of junk.

Is there a way to 'mute' the ouput of the script, similar to windows @echoff? I saw on another question very similar to mine, not the same though that you could use scriptname >/dev/null. When I put this in my program, obviously replacing scriptname with the name of the script, I got a command not found error message.

Does anyone have any idea why this might be happening.

1
  • Because of a typo, for example. Or because the script calls a command that's not available, in which case the shell will print the error message to stderr as opposed to stdout (which is not redirected by > /dev/null). Without knowing your code and the way you call it, all is guesswork. Commented Mar 2, 2015 at 21:12

2 Answers 2

5

If you mean you want to redirect all output to /dev/null from within the script, rather than when you execute the script, you can do this:

#!/bin/bash
echo Hi

and run that, like this

./script

then do this

#!/bin/bash
exec 1> /dev/null
echo Hi

and run it again exactly the same way, and see that the output is discarded.

Sign up to request clarification or add additional context in comments.

Comments

2

You wouldn't put that in your program, but rather, would use it when calling your program. On the command line:

$ scriptname >/dev/null

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.