• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Secure settings and run command

lotus49

Android Expert
I am trying to get my S4's IP address using Tasker. The Secure Settings plugin allows me to run a Linux command so I have set it up to run this command

Code:
ifconfig wlan0 | awk '{print substr($0, 11, 13)}'
The command works fine at the command line and if I turn on the Show Output and Show Notification check boxes I get the output I expect.

Just in case there are any other Unixers reading this I know cut would have been simpler than awk but it didn't work. I also know this command assumes that the IP address will necessarily be 13 chars long when it won't always be - I'll sort these issues out later.

The only variable I have set in Secure Settins is %IPADDR which is set as the Output Variable. However, after I run the command, this variable has no value, whereas I expected it to include the output of the above command ie my IP address.

Does anyone know what I am doing wrong?
 
Use script/runshell instead of plugins/secure settings. In runshell:

Command: ifconfig wlan0 | awk '{print substr($0, 11, 13)}'
Timout:0
Use Root: Unchecked
Store Output In: %IPADDR
 
Thank you. After a bit of faffing about debugging my script (SwiftKey starts inserting an deleting spaces seemingly at random - I presume it's trying to be clever) that worked.
 
Back
Top Bottom