Make certain you enter the command correctly. The answer given is an example of command output substitution within the bash (and similar) shell.
From original answer:
Code: Select all
_IP=`wget -q -O - http://icanhazip.com/ | tail`
Note: that those are back-tick characters surrounding the command and not single quote characters. On my US keyboard, the back-tick is located to the left of the number one key.
For reference:
Code: Select all
' --> single quote
` --> back qoute/back-tick
" --> double quote
If you want to use your original example site, you can use it in the same way:
In scripting for bash (and similar), enclosing a command in back-ticks is an indication to run the command and use the command output inline. So, using your command as an example, typing at command prompt gives (ip replaced with xx.xx.xx.xx):
Code: Select all
$ curl -s http://ifconfig.me
xx.xx.xx.xx
Executing the script line previously given, after the shell executes and performs substitution, would be equivalent to:
The _IP variable is assigned the command output.
The example you linked to has a Python script also. To perform an equivalent in the Python script requires you to update the IP request command with:
Code: Select all
arg='curl -s http://ifconfig.me'
p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE)
Single quotes this time...
Enjoy!
Bill