2011-03-05 91 views
2

通過telnet(在遠程服務器上沒有ssh)運行「遠程」shell,我需要等待遠程shell結束髮送連接關閉I/O「睡眠」 。Linux如何等待遠程pid(telnet)

。 my_local_shell |遠程登錄

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

我需要相當類似:

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

但我無法得到它的工作,因爲我想遠程pid是「混合」與當地的一個。

如何實現這一目標?

回答

1

您需要擺脫美元符號。

echo "wait \$!" 

echo 'wait $!' 

你現在的樣子,特變在當地殼被擴大。通過轉義它,擴展會延遲遠程shell執行的操作。

+0

thx這個解釋(擴展),我得到它的工作時逃避$與一個單一的遠程過程。關鍵是遠程shell也運行孩子,等待相同的PID,並且在那裏我掙扎着。但我會在父母/孩子的pid中進一步研究。我已經看到一些關於這[這裏]的好文檔(http://mywiki.wooledge.org/EnglishFrontPage) – hornetbzz 2011-03-05 05:45:16