我需要知道其被作为一个命令在bash脚本像NMAP扫描等作为创建进程时,我可以显示一个杆或旋转器
#!/bin/sh
G='\033[0;32m'
B='\033[0m'
${G}Enter IP TAIL LIKE 0.1 OR 1.1${B}"
read v
${G}ENTER Device NAME ${B}"
read k
nmap -A -Pn -sV 192.168.$v -oN /tmp/op
//here i want a while loop for displaying a spinner
执行的另一过程的pid
作为PID死其完成时,我可以把它作为一个计数或标志或类似的结束微调的东西编辑代码更新Thts the code in case tht was not visible properly ^^。我工作的卡利nethunter。
P.S这是我第一次在堆栈溢出PLS如果太愚蠢原谅我还是告诉我,如果我错过了什么。
一个出发点:
#!/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
*问题解决了由于*卡米尔CUK