【发布时间】:2014-11-20 08:51:14
【问题描述】:
我希望在单行 shell 中完成以下工作。
curl -s icanhazip.com | ssh user@host 'php /path/to/script.php "[PASS_IP_HERE]"'
我需要将我的本地 IP 传递给远程服务器,最好是一行。
今天我是这样做的:
curl -s icanhazip.com // manually copy result
ssh user@host 'php /path/to/script.php "[PASTE_RESULT_HERE]"'
假设本地IP为1.2.3.4,远程IP为5.6.7.8,那么期望的结果更接近:
> curl -s icanhazip.com
1.2.3.4
> ssh user@5.6.7.8 'php /path/to/script.php "1.2.3.4"'
// How can I pass this dynamically? ---^
【问题讨论】:
标签: shell curl command-line