Reputation: 1818
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.
Upvotes: 0
Views: 845
Reputation: 207465
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.
Upvotes: 5
Reputation: 12924
You wouldn't put that in your program, but rather, would use it when calling your program. On the command line:
$ scriptname >/dev/null
Upvotes: 2