I wish to club the below two Steps whereby the output of Step 1 i.e the PORTS should go as input to Step 2.
Step 1:
The below command gets me the port numbers from a file.
genpwdfile dec -in test/test.cfg -out /tmp/dec.out |grep PORT_NUM /tmp/dec.out | cut -d '=' -f2 ; grep MONITOR_PORT /tmp/dec.out | cut -d '=' -f2
Output:
33027
13041
Step 2:
The below command kills the PID [which comes as output of Step 1] occupying the ports.
lsof -i:33027 2>/dev/null | grep -v PID | awk '{print $2}' | xargs kill -9
lsof -i:13041 2>/dev/null | grep -v PID | awk '{print $2}' | xargs kill -9
Sample /tmp/dec.out
Test_DIR=/tmp
PORT_NUM=33027
TEST_PORT_WORK=7777
MONITOR_PORT=13041
I'm dealing with AiX 6.1 System
Can you please suggest ?
genpwdfile
command if you then justgrep PORT_NUM /tmp/dec.out
? You aren't connecting these in any way. – terdon Nov 23 '20 at 10:22genpwdfile
createsdec.out
file – Ashar Nov 23 '20 at 11:06grep PORT_NUM /tmp/dec.out
? And what does the secondgrep
do? The one ingrep MONITOR_PORT /tmp/dec.out
? – terdon Nov 23 '20 at 11:08