Last active
December 22, 2015 04:27
-
-
Save aminamid/dd0ee8f65385eaa50285 to your computer and use it in GitHub Desktop.
リモートホスト上で、ローカルにあるスクリプトを動かす ref: http://qiita.com/aminamid/items/459ba9e77cecc736315f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./sample.sh a b c | |
2015-12-22T11:30:26 local-host init | |
2015-12-22T11:30:27 local-host a | |
2015-12-22T11:30:28 local-host b | |
2015-12-22T11:30:29 local-host c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat sample.sh | ssh user@remote-host | |
2015-12-22T11:31:43 remote-host init |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat sample.sh | bash <(cat -) a b c | |
2015-12-22T11:33:47 local-host init | |
2015-12-22T11:33:48 local-host a | |
2015-12-22T11:33:49 local-host b | |
2015-12-22T11:33:50 local-host c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat << 'EOT' | bash <(cat -) a b c | |
> for arg in init ${@};do | |
> echo "$(date +%Y-%m-%dT%H:%M:%S) $(hostname) ${arg}" | |
> sleep 1 | |
> done | |
> EOT | |
2015-12-22T11:40:17 local-host init | |
2015-12-22T11:40:18 local-host a | |
2015-12-22T11:40:19 local-host b | |
2015-12-22T11:40:20 local-host c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./rdosh.sh sample.sh a b c | ssh user@remote-host | |
2015-12-22T11:42:48 remote-host init | |
2015-12-22T11:42:49 remote-host a | |
2015-12-22T11:42:50 remote-host b | |
2015-12-22T11:42:51 remote-host c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./sample.py a b c | |
2015-12-22T13:20:29 local-host init | |
2015-12-22T13:20:30 local-host a | |
2015-12-22T13:20:31 local-host b | |
2015-12-22T13:20:32 local-host c | |
$ ./rdopy sample.py a b c | ssh user@remote-host | |
2015-12-22T13:20:46 remote-host init | |
2015-12-22T13:20:47 remote-host a | |
2015-12-22T13:20:48 remote-host b | |
2015-12-22T13:20:49 remote-host c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo -e "cat << 'EOT' | python <(cat -) ${@:2}\n$(cat ${1}|sed -e 's/\\/\\\\/g')\nEOT" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo -e "cat << 'EOT' | bash <(cat -) ${@:2}\n$(cat ${1}|sed -e 's/\\/\\\\/g')\nEOT" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo -e "cat << 'EOT' | bash <(cat -) ${@:2}\n$(cat ${1})\nEOT" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import os | |
import time | |
for arg in ["init"]+sys.argv[1:]: | |
sys.stdout.write("{0} {1} {2}\n".format(time.strftime("%Y-%m-%dT%H:%M:%S"),os.uname()[1],arg)) | |
sys.stdout.flush() | |
time.sleep(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for arg in init ${@};do | |
echo "$(date +%Y-%m-%dT%H:%M:%S) $(hostname) ${arg}" | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment