我正在尝试nc
从脚本执行命令,我的脚本nc
使用相同的源端口在目标的不同端口上执行命令。
例如:
nc -p 8140 -z -v -n 10.X.X.9 9090
nc -p 8140 -z -v -n 10.X.X.9 9091
nc -p 8140 -z -v -n 10.X.X.9 9092
nc -p 8140 -z -v -n 10.X.X.9 9093
and so on ...
Run Code Online (Sandbox Code Playgroud)
在第一次 nc 执行之后,对于所有行的其余部分,我收到了下面提到的错误消息。
nc: bind failed: Address already in use
nc: bind failed: Address already in use
nc: bind failed: Address already in use
Run Code Online (Sandbox Code Playgroud)
有没有办法避免这种情况?
我正在编写一个脚本,我试图在其中导出一些变量,并且在打印时导出我的变量后,它会在它之后打印额外的一行。
在这里,我正在读取包含两列的 csv 文件。该脚本存在于文件 script.sh 中,我正在执行该文件 ./script.sh
#!/bin/bash
while IFS="," read f1 f2
do
echo "Source IP : $f1" #it is printing without extra line
echo "Destination IP : $f2" #it is printing without extra line
export sourceIP=$f1
export destIP=$f2
ssh -t -t sjain@$f1 <<ENDSSH
#Start copying 33KB File
echo "Destination IP Address: $destIP" # here it is printing an extra line after destIP
startTime=$(($(date '+%s%N')/1000000))
scp KB_33.txt sjain@$destIP:/home/sjain
endTime=$(($(date '+%s%N')/1000000))
printf 'Elapsed time in copying 33KB file: %s\n' $((endTime-startTime)) …
Run Code Online (Sandbox Code Playgroud) 我有一个脚本,我在其中从包含 .csv 文件的 csv 文件中读取SourceIp, DestinationIP,Source Ports, Destination Ports
。
首先,我正在读取 sourceIp 并尝试对其执行 ssh(我能够成功完成),在这里我试图获得一个伪终端并希望执行一个 for 循环,该循环将迭代 sourcePorts(连字符分隔)和目的地端口。
输入文件内容:
10.X.X.9,10.X.X.23,8140-61613,1521-1524-1525-1526-1530-1531-8140-61613
Run Code Online (Sandbox Code Playgroud)
脚本 :
export lastSourceIP=""
export lastDestinationIP=""
export fqdn=""
export sourceFqdn=""
x=0
export username="sjain";
export location="/home/sjain/poc";
export baseLocation="10.X.X.9"
while IFS="," read f1 f2 f3 f4
do
x=$(($x+1))
TMP=$(mktemp)
TMP2=$(mktemp)
echo "Source IP : $f1"
echo "Destination IP : $f2"
echo "Source Ports : $f3"
echo "Destination Ports : $f4"
export sourceIP=$f1
export destIP=$(echo "$f2" | tr -d '\n')
export port=$(echo "$f3" …
Run Code Online (Sandbox Code Playgroud)