Running netstat command in AIX- via task

(imported topic written by SystemAdmin)

I am trying to create a task to run the netstat command, and to output the results to the file.

Being pretty green in AIX I could use some assistance.

Action script is simple:

wait netstat -an > “/tmp/netstattest.log”

What am I missing? The log is never created on the endpoint. Im not sure if the scan ever took place either.

(imported comment written by SystemAdmin)

Ok, I am working with a new script in the sh script dialog.

Below is my action:

#!/bin/sh

wait netstat -an > /tmp/netstat8302011.log

It completes correctly, but creates an empty file. Working with my AIX team to determine why… maybe you can beat them

(imported comment written by NoahSalzman)

try something like

wait /bin/sh -c ‘netstat -an > /tmp/netstat8302011.log’

(imported comment written by SystemAdmin)

Thanks Noah. Same result. Looking like a rights issue, which concerns me since the agent is doing the work.

(imported comment written by SystemAdmin)

Hi,

If you’re running the netstat command from a shell script you don’t need the ‘wait’. You might also consider putting the full path name into the command string, i.e. /usr/bin/netstat

There shouldn’t be any privilege issues as the netstat can be executed (wrongly in my opinion) by any user.

Mark.

(imported comment written by SystemAdmin)

thanks on this too, Cider. However this command didnt work at all. Ill keep plugging away, but open to more ideas.

(imported comment written by SystemAdmin)

While using the following, the task completed, and DOES create the output file under temp, but there are no contents.

#!/bin/sh

wait sh -C netstat -an > /tmp/netstat8302011.log

any ideas?

(imported comment written by SystemAdmin)

Boy as a non AIX guru, this is frustrating.

Agent runs as root. Netstat does seem to run, as the output log is created, however the log is empty.

(imported comment written by SystemAdmin)

Survey says!!!

#!/bin/sh

/usr/bin/sh -c "/usr/bin/netstat -an" > /tmp/netstat8312011.txt