Custom Commands and pipe

Hi,
when I use “Custom Commands” pipe
smartctl -a / dev / sda | grep Temp | cut -d “” -f 2.37

I get refunded …

# smartctl -a /dev/sda "|" grep Temp "|" cut "-d " -f "2,37"
smartctl 6.5 2016-05-07 r4318 [armv7l-linux-4.4.13-05df79f63527051ea0071350f86faf76-9] (localbuild)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=======> INVALID ARGUMENT TO -f: 2,37
=======> VALID ARGUMENTS ARE: old, brief, hex[,id|val] <=======

Use smartctl -h to get a usage summary

How do I do I specify “Custom Commands” to dotstal same dump when I run the command ssh.

Thank you

David

PS: The drive is connected via SATA and ssh works properly.

Do not use quotes around the |

smartctl -a /dev/sdb | grep Temp | cut "-d " -f "2,37"

Giving commands
smartctl -a / dev / sda | grep Temp | cut -d “” -f 2.37

But the interface is interpreted as
smartctl -a / dev / sda “|” grep Temp “|” cut “-d” -f “2.37”

:frowning:

Seems everything following the initial command is treated as an argument.
A workaround is to create a script with your command and run that script from Luci.

I created a small script, put it into /usr/bin and it works fine. Here it is:

root@turris:~# cat /usr/bin/pipe_test 
#!/bin/sh
cat /proc/cpuinfo | grep -m 1 model | cut -d' ' -f 3,7

Don’t forget to make the script executable like this:

root@turris:~# chmod +x /usr/bin/pipe_test

Added it under Custom Commands → Configure and ran it successfully

Thanks this work.

But when i get link for this script, Luci return this log…

No page is registered at ‘/admin/system/commands/dashboardcommand/cfg089944’.
If this url belongs to an extension, make sure it is properly installed.
If the extension was recently installed, try removing the /tmp/luci-indexcache file.

When i delete “/tmp/luci-indexcache”, link from Luci rerturned the same message.

Where is problem?

Thanks for help.

Months later, I’m still having this issue. I can’t get a link-able command working. I don’t know if this is an issue with me (for testing purposes, my custom command is very simple, a simple pwd command) or whether it’s a bug with Turris OS.

Hi,

Actually I ran into this issue too - I have two public commands defined to reset my vpn tunnels, neither of which work from the generated bookmark. I too get a similar error so suspect this is likely a bug.

Cheers,
ChaZ

@thencein So, I did some poking around & it looks like the luci generated link location is incorrect but the public links do actually work, you just need the right url…

Once you have created your custom command it will generate a link similar to:

https://[yourip]/cgi-bin/luci/admin/system/commands/dashboardcommand/cfg089944 (which won’t work)

Try:
https://[yourip]/cgi-bin/luci/command/cfg089944 (and it should be fine!)

Obviously, substitute the value of cfg089944 with the one from the link generated for your commands and you should be good to go.

Cheers,
-ChaZ-

1 Like

Awesome! I just tried it out and it works perfectly. Thanks.