Sunday, December 4, 2022

#1 2022-11-07 08:07:11 pm

mcsprodart
Member
Registered: 2013-03-09
Posts: 32

do shell script

I've tried a few ways to do something that used to be easier before Ventura....running a shell script that uses a file and writes it. Now I get -

"\r--- FILE infile.png DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO size ---\r"



running code:

tell current application
   set theCommand to "myShell.sh quoted form of inFile & " " & quoted form of outFile"
   do shell script theCommand
end



or

tell current application
   set theCommand to "/bin/bash myShell.sh quoted form of inFile & " " & quoted form of outFile"
   do shell script theCommand
end



runs fine directly in Terminal.
I gave full disk access to script debugger.
Any suggestions?


Filed under: shell, Ventura

Offline

 

#2 2022-11-08 07:37:29 am

robertfern
Member
Registered: 2011-11-29
Posts: 225

Re: do shell script

I don't think this code snippet could ever work as it is not formatted correctly.

First, is myShell.sh in a directory that is part of the PATH shell variable?
Otherwise you would need to put the full path to it.

Second, Quoted form of inFile is being sent as actual text because of the missing quote

set theCommand to "myShell.sh quoted form of inFile

should be

set theCommand to "myShell.sh " & quoted form of inFile



Third, you have an ending quote that should not be there

set theCommand to "myShell.sh quoted form of inFile & " " & quoted form of outFile"

should be

set theCommand to "myShell.sh " & quoted form of inFile & " " & quoted form of outFile

Last edited by robertfern (2022-11-08 07:38:58 am)

Offline

 

#3 2022-11-08 09:19:40 am

mcsprodart
Member
Registered: 2013-03-09
Posts: 32

Re: do shell script

Your right. In my haste to post the code and simplifying I failed to check the details. I still receive the same error and had it correct in my actual script. I believe I have narrowed it to the fact that I am triggering a shell script from AppleScript in Ventura/OS 13 and that it is reading a file and performing some complicated imagemagick commands and specifying the outFile. It worked fine in all previous OS versions and can be run directly from terminal in bash or zsh.

I have given execute permissions to the shell script and given script debugger access to full drive.

The shell script successfully creates a folder in the /tmp directory but does not have permission to read the file in the given path inFile and I am assuming will not be allowed to write the outFile.

The inFile posix path is /users/username/Desktop/somefolder/somefile.png

Any thoughts on this? I was sure it was a Ventura issue a script executing bash script but now uncertain why it would allow a folder to be created in /tmp if it will not allow reading a file.

Offline

 

#4 2022-11-08 12:32:34 pm

mcsprodart
Member
Registered: 2013-03-09
Posts: 32

Re: do shell script

Problem solved....

a few items had to change:

1. moving the Shell Script to my user directory solved it the permission issue when running from script debugger app. I guess until I sign the bundle which I usually do when export read only, the permissions may not work even though the shell script had execute permission. Seems similar to library permission issues.

2. I was using "." as the temp directory and Ventura wouldn't allow so I used "/tmp"

3. Another issue not encountered prior to Ventura was inside the shell script I used convert and magick commands to manipulate the image file and were "not found". I updated the commands to be exact paths to the binary files to: /usr/local/bin/magick & /usr/local/bin/convert. (M1/M2 installs would be a different path which can be found using Whereis magick in terminal).

Hopefully this will help someone in future.


Filed under: shell, Imagemagick, Ventura

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)