Jump to content

SSH/Shell - How to save results to a file?


ianh

Recommended Posts

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

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.