Last active
January 12, 2017 05:58
-
-
Save klang/e5364f0f5dcd17c0fb461f41940538c6 to your computer and use it in GitHub Desktop.
user is logged in on a ssh connection and has to call a rest service running on his local machine
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 | |
| foo=$(pstree -c -p -s $$ | awk -Fsshd '{print $3}' | cut -f2 -d '(' | tr -d ')' | tr -d '-') | |
| caller=$(who -u | grep $foo | cut -f2 -d '(' | tr -d ')') | |
| # a few other ways to get the IP | |
| TTy=$(ps -eo pid,tty|grep $$|awk '{print $2}') | |
| WhoAmI=$(who -u |grep -e "$TTy") | |
| TheIp=$(echo $WhoAmI | awk '{print $7}' | sed 's/[()]//g' | |
| read INPUT | |
| curl --header "Content-type: application/json" --request POST --data $INPUT http://$caller/rest/service | |
| # user is logged in on a ssh connection and has to call a rest service running on his local machine | |
| # cat json-data.json | call-rest-service-on-caller-machine.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment