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. Link to comment https://forums.phpfreaks.com/topic/147927-sshshell-how-to-save-results-to-a-file/ 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 Link to comment https://forums.phpfreaks.com/topic/147927-sshshell-how-to-save-results-to-a-file/#findComment-776371 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 :-) Link to comment https://forums.phpfreaks.com/topic/147927-sshshell-how-to-save-results-to-a-file/#findComment-776386 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. Link to comment https://forums.phpfreaks.com/topic/147927-sshshell-how-to-save-results-to-a-file/#findComment-776392 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.