Execute a shell script file
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Execute a shell script file
Hi all!
I'm searching the best way to execute a shell script file giving the path. In a topic I read that you could just launch the file as openURL but I'm new in this topic so I'm not sure if this could be the right way.
PS
It would be very fine also whether there is the possibility to give some optional shell parameters.
I'm searching the best way to execute a shell script file giving the path. In a topic I read that you could just launch the file as openURL but I'm new in this topic so I'm not sure if this could be the right way.
PS
It would be very fine also whether there is the possibility to give some optional shell parameters.
Re: Execute a shell script file
Hi Mag,Mag wrote: I'm searching the best way to execute a shell script file giving the path. In a topic I read that you could just launch the file as openURL but I'm new in this topic so I'm not sure if this could be the right way.
Have you checked the shell and shellCommand in the Dictionary?
This is quite well explained.
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: Execute a shell script file
Hi Thierry,
thank you. Any suggestion to run a shell script located on an external file?
thank you. Any suggestion to run a shell script located on an external file?
Re: Execute a shell script file
Umm, not really as I don't know what you want/need to achieveMag wrote:Hi Thierry,
thank you.
Any suggestion to run a shell script located on an external file?

But here is one way:
in a file, ie: /full/path/of/this/file.sh
Code: Select all
#!/bin/bash
echo "Hello LC with $1"
Code: Select all
put 42 into x
put shell("/full/path/of/this/file.sh " & quote & x & quote )
Hope this gives you a start.
Regards,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: Execute a shell script file
Hi Thierry, thank you, very useful post.
What I'm try to do is to give the user the possibility to run a shell script from within an app. I thought that the best way could be to let user to choose a file from the Finder and then run it, but an alternative could be to give the user a text field and then run the content.
I do not know the differences in results between the two methods, if any, so I would be happy to have advices and suggestions.
What I'm try to do is to give the user the possibility to run a shell script from within an app. I thought that the best way could be to let user to choose a file from the Finder and then run it, but an alternative could be to give the user a text field and then run the content.
I do not know the differences in results between the two methods, if any, so I would be happy to have advices and suggestions.
Re: Execute a shell script file
HI Mag,Mag wrote:Hi Thierry, thank you, very useful post.
What I'm try to do is to give the user the possibility to run a shell script from within an app. I thought that the best way could be to let user to choose a file from the Finder and then run it, but an alternative could be to give the user a text field and then run the content.
I do not know the differences in results between the two methods, if any, so I would be happy to have advices and suggestions.
there are not much differences for most cases,
except if:
- the size of your shell scripts are more than few MegaBytes

- you're calling your shell script hundred of times per second.
If you like having all your programs or files in one place, I would suggest
storing your shell script in a field, or a custom property or even in a Database.
LC is quite good for that.
If you work in team and have a shell expert; might be better to let this guy managed
a bunch of files on his own and, within LC, call them.
I would avoid typing shell scripts straight in the LC editor, otherwise
you'll have to deal with few levels of evaluation (means that you need to escape
a lot of chars in your shell script) and you'll have an ugly and hard to read piece of code.
As you said you're new to this, might be interesting for you to explore both ways?
Good luck,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: Execute a shell script file
Hi Thierry, thank you so much for your help and very useful advice. Much appreciated!