Open and close programs from macro

Hi All,

I am writing a macro attached to a spread sheet, the basic function is that I enter information relating to a document I need to scan, it looks in the default folder for the scanner say /home/scan/ when it sees a file it renames this based on the information supplied in the form, All good so far.

What I want is for the macro to open simple-scan when it runs, I have done this with the line below

Shell("/usr/bin/simple-scan",0)

My problem is closing simple-scan from the macro

I have tryed this below

shell(“kill simple-scan”)

shell(“kill /usr/bin/simple-scan”)

which to be fare doesn’t work in terminal either it gives this

bash: kill: simple-scan: arguments must be process or job IDs

next I tried

kill_simple = shell(“pgrep simple-scan”)

to get the prosses number with the hope of using something like this

kill_simple = shell(“pgrep simple-scan”)

shell(“kill + kill_simple”)

but kill_simple always comes up with a value of Zero

Any Ideas anyone

Regards Neil

Hello @Neil-B,

you could try "pidof simple-scan" to get the process ID of the running simple-scan process,

HTH, lib

Hi Thanks for your quick answer,
I tried 'pid = shell(“pifof simple_scan”) but pid has a value of zero.
pidof simple_scan in terminal gives me say “1234” for instance,
now if I try ‘shell(“kill 1234”)’ that works, somthing in the middle not working
I had thought about writing a bash script to do the job but I would sooner get this working if I can

Neil

please try with pkill:
Shell( "pkill simple-scan" )

1 Like

Hello again,
Yes that worked very well,
with me trying this over and over I had about 15 simple_scans running at once and they all shut down for me.
thank you very much for your help

Neil