I have been working on this a bit, and I cannot get any of the command.json files (in the tools folder) to work. First, I am running a Raspberry Pi attached to the printer (JR 1.0) via usb
this is the json file
{
"name":"send file to printer",
"cmd":"/bin/bash -c 'mv tmp-toolArg0upload "$0".gcode;threedub -p "$0".gcode' $1",
"usesPrinterConnection":true,
"formfields":[
{
"type":"file",
"name":"Select the gcode file to upload and print",
"discription":"select file"
}
]
}
error:
tmp-toolArg0upload': -c: line 0: unexpected EOF while looking for matching `''
tmp-toolArg0upload': -c: line 1: syntax error: unexpected end of file
error exit status 1
let me explain the command portion of the cmd line
/bin/bash -c 'mv tmp-toolArg0upload "$0".gcode;threedub -p "$0".gcode' $1
as you know, the bash commands (bash -c executes the commands from a string; ie. everything inside the quote) need to be quoted. In order to pass commands to this, the arguments ($0) need to be double quoted or else they are not expanded. $0 is the first argument when passed this way
Also, when passing commands to a bash script, the first argument is $1 ( $0 is the bash command when executing.
Very confusing with these different first argument position ( 0 or 1) and the quoting ( single, double)
Now, if I execute this script ( after having the tmp-toolArg0upload file available ) it works, i.e. renames the file to the correct gcode and then passes it to threedub for conversion and printing.
bash script:
#/bin/bash
/bin/bash -c 'mv tmp-toolArg0upload "$0".gcode; threedub -p "$0".gcode' $1
This also will work
#/bin/bash
/bin/bash -c "mv tmp-toolArg0upload "$1".gcode; threedub -p "$1".gcode"
So, why the error above. I think that your requirement of having the complete command in double quotes, bash's requirement to have single quotes for the string of bash commands ( when using bash -c ) and bash's requirement to have the double quotes to have the arguments expanded causes the error.
I do not know how to proceed. This happens on any command.json that is passing arguments