开发者

Linux how to wait for remote pid (telnet)

开发者 https://www.devze.com 2023-02-14 18:57 出处:网络
Running a \"r开发者_运维知识库emote\" shell via telnet (no ssh on the remote server), I need to wait for the remote shell end to sending the connection closure i/o \"sleep\".

Running a "r开发者_运维知识库emote" shell via telnet (no ssh on the remote server), I need to wait for the remote shell end to sending the connection closure i/o "sleep".

. my_local_shell | telnet

#!bin/bash
# run remote shell
echo "remote_shell.sh \"required_parameters\""
sleep 30
echo close XX

I need rather something like :

# run remote shell
echo "remote_shell.sh \"required_parameters\" &"
echo "wait $!"
echo close XX

But I could not get it working as I guess the remote pid is "mixed" with the local one.

How to achieve this ?


You need to escape the dollar sign.

echo "wait \$!"

or

echo 'wait $!'

The way you have it now, the special variable gets expanded in the local shell. By escaping it, expansion gets delayed for the remote shell to do.

0

精彩评论

暂无评论...
验证码 换一张
取 消