ianh Posted March 4, 2009 Share Posted March 4, 2009 Hi everyone, I want to know how I can save results generated from a Shell command to a file? For example I have entered the Shell command.. netstat -lnptu ..to show me the active ports on my server. How can I save this list of ports to a text file? Your help much appreciated. Quote Link to comment Share on other sites More sharing options...
Maq Posted March 4, 2009 Share Posted March 4, 2009 I think you can just do: netstat -lnptu > ports.txt Quote Link to comment Share on other sites More sharing options...
ianh Posted March 4, 2009 Author Share Posted March 4, 2009 I think you can just do: netstat -lnptu > ports.txt Thanks Maq, but where would ports.txt get saved to? How would I save it to a specific directory? As you can tell I'm a complete Shell newbie :-) Quote Link to comment Share on other sites More sharing options...
Maq Posted March 4, 2009 Share Posted March 4, 2009 Thanks Maq, but where would ports.txt get saved to? The command I gave you saves ports.txt in the current directory you're in. How would I save it to a specific directory? You have to specify what directory you want to save it in. i.e. netstat -lnptu > /home/tim/ports.txt This would save ports.txt into my home directory. You can hard code a path but that's dangerous if you ever use this script on a different server. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.