我需要知道另一个进程pid,它作为bash脚本中的命令执行,如nmap扫描等,因为创建进程时我可以显示一个条形或一个微调器
#!/ bin / sh的 G = …
一个起点:
#!/bin/bash echo "Enter IP:" read -r ip # `&` runs in parallel # always quote variables nmap "$ip" & # `$!` get's the background process PID pid=$! ... # you can see if a pid is running by checking exit status of `kill -0` while kill -0 "$pid" 2>&1 >/dev/null; do printf ... ... done
nmap -A -Pn -sV 192.168.0.1 -p -oN /tmp/op >/dev/null & pid=$! i=1 sp="/-\|" echo -n ' ' while kill -0 "$pid" 2>&1 >/dev/null; do printf "\b${sp:i++%${#sp}:1}" done
的 *问题解决了* 强> 卡米尔库克