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