problem using [FILTER} to run a bash script

More
05 Nov 2021 23:16 #225446 by ericg
Hi, I wrote a simple 2 line bash script to modify a Lightburn generated .gc file to run on LCNC, the script works fine from the command line.

my [FILTER] section includes ..
[FILTER]
...
PROGRAM_EXTENSION = .ngc,.gc Bash Script
....
gc = RunSED

I checked permissions etc and see nothing wrong, I tried using the .sh extension but still same result which is an error message saying "can't open /tmp/tmpxxxx/filename.gc" and also "file ended with no percent sign"
when I checked the tmpxxx file it was empty.
Other files such as a jpg works OK with image-to-gcode and I placed my RunSED file in the same place with the same permissions.
I assume LCNC is trying to place a copy of the original file into a tmp location to work on it but that it cannot seem to copy it properly.

Any suggestions would be appreciated
Eric

Please Log in or Create an account to join the conversation.

More
07 Nov 2021 22:27 #225595 by tommylight

PROGRAM_EXTENSION = .ngc,.gc Bash Script
....
gc = RunSED

If that is exactly how you have it in the ini file, "bash script" can not be there, but i guess this is the forum editor messing up formatting.
You should attach the ini file here so we can have a look, pretty rusty since i last used this option for my needs.

Please Log in or Create an account to join the conversation.

More
07 Nov 2021 23:55 #225603 by andypugh
Does the bash script start with the correct "#! ...." ?

Please Log in or Create an account to join the conversation.

More
08 Nov 2021 01:35 #225617 by ericg
Thanks for the response's guys, yes, the bash script does have the correct shebang and I put 'Bash Script' in following the python script example, I'll try it without "Bash Script"I have attached the .ini file and my executable bash script, (I put .txt extension on just so it would attach without error, that should be removed)
Thanks
Eric
Attachments:

Please Log in or Create an account to join the conversation.

More
08 Nov 2021 04:34 #225624 by cmorley
What screen are you using?

Please Log in or Create an account to join the conversation.

More
08 Nov 2021 06:40 #225629 by ericg

Please Log in or Create an account to join the conversation.

More
08 Nov 2021 06:51 #225631 by cmorley
Here is the relevant code in axis. maybe that helps.
Looks like error checking/printing is sparse.
progress_re = re.compile("^FILTER_PROGRESS=(\\d*)$")
def filter_program(program_filter, infilename, outfilename):
    import subprocess
    outfile = open(outfilename, "w")
    infilename_q = infilename.replace("'", "'\\''")
    env = dict(os.environ)
    env['AXIS_PROGRESS_BAR'] = '1'
    p = subprocess.Popen(["sh", "-c", "%s '%s'" % (program_filter, infilename_q)],
                          stdin=subprocess.PIPE,
                          stdout=outfile,
                          stderr=subprocess.PIPE,
                          env=env)
    p.stdin.close()  # No input for you
    progress = Progress(1, 100)
    progress.set_text(_("Filtering..."))
    stderr_text = []
    try:
        while p.poll() is None: # XXX add checking for abort
            t.update()
            r,w,x = select.select([p.stderr], [], [], 0.100)
            if r:
                stderr_line = p.stderr.readline()
                m = progress_re.match(stderr_line)
                if m:
                    progress.update(int(m.group(1)), 1)
                else:
                    stderr_text.append(stderr_line)
                    sys.stderr.write(stderr_line)
        # .. might be something left on stderr
        for line in p.stderr:
            m = progress_re.match(line)
            if not m:
                stderr_text.append(line)
                sys.stderr.write(line)
        return p.returncode, "".join(stderr_text)
    finally:
        progress.done()

def get_filter(filename):
    ext = os.path.splitext(filename)[1]
    if ext:
        return inifile.find("FILTER", ext[1:])
    else:
        return None

Please Log in or Create an account to join the conversation.

More
08 Nov 2021 07:02 #225632 by ericg
Thanks, but I'm no programmer so it doesn't help me, perhaps someone more knowledgeable can use it but for now if it's an issue within LCNC then I will just have to live with running the script manually from the command line,
At least I know it's not me.
Eric

Please Log in or Create an account to join the conversation.

More
08 Nov 2021 08:43 - 08 Nov 2021 08:44 #225639 by cmorley
Try:

PROGRAM_EXTENSION = .ngc Gcode
PROGRAM_EXTENSION = .gc Bash Script

gc = sh
Last edit: 08 Nov 2021 08:44 by cmorley.

Please Log in or Create an account to join the conversation.

More
08 Nov 2021 10:14 #225655 by ericg
Just tried that and the sh command tried to interpret the file as a shell script and consequently every line failed, but it did at least read the file, I tried renaming my script as RunSED.sh but that was no help either.
Thanks for the thought.

Please Log in or Create an account to join the conversation.

Time to create page: 0.115 seconds
Powered by Kunena Forum