# 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

edit retag close merge delete

Sort by » oldest newest most voted

Hello @Neil-B,

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

HTH, lib

more

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

( 2017-09-10 21:24:23 +0200 )edit

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

( 2017-09-10 21:54:08 +0200 )edit

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

( 2017-09-10 22:56:03 +0200 )edit