nalbee
March 1, 2018, 2:49pm
1
Trying to run this command. which produces in a terminal in debian free memory , example value: 976
free -m | grep ^Mem | tr -s ’ ’ | cut -d ’ ’ -f 2
Using cfexecute:
<cfexecute name = "/usr/bin/free"
arguments = " -m | grep ^Mem | tr -s ' ' | cut -d ' ' -f 2 "
variable="totalmemory" timeout = "10">
</cfexecute>
It generates this error:
Error invoking external process
Detail: free: seconds argument failed: '|': Invalid argument
Anyone know why I would get that error and how can I overcome it.
Run the command as a bash script versus directly trying to execute the program.
nalbee
March 1, 2018, 3:12pm
3
I’ll try that. that is a really good idea. Thanks for suggesting that.
nalbee
March 1, 2018, 3:21pm
4
That worked great. Thanks a bunch for that suggestion.
To expand on why was not working – I don’t think cfexecute supports pipes | - when you pipe a command you are creating multiple processes.
1 Like
You would need to make your executable file be bash itself (/bin/sh) and then pass the whole thing as a command. Which is more less what you’re doing when you just execute a shell script. This is how the “run” command in CommandBox operates.
1 Like