Posixscript and shellscript failures

I have an issue with posix- and shellscript. It seems neither will write a file to disk when redirection is used … this gives an error:

SHELL ERROR: sh: filename.txt: Read-only file system

Is this the expected behavior?

fCommand = {head -1 } + posixpath(fileChoice) + { | iconv -s -f UTF-16LE > output.txt}
fileEncode = posixscript(fCommand)


fileEncode = shellscript(fCommand)

where fileChoice is a file path chosen via choosefiledialog.

I’m far from a unix expert! Do others see this behavior, and if so any ideas why?



Well, I’m not a unix expert either, but my guess is that you are trying to write your output.txt file to a location where you don’t have write permission. You might try including the path.


Thanks, you solved it. I was too deep in the woods …

The correct code is above.



I came up with a test to see where the original code was probably trying to save the file. I used ls, without specifying the directory, to see which directory it would treat as the default.

The result in Terminal is on the left, and the result returned by posixscript( is on the right. Terminal listed the contents of my home directory, and posixscript listed my root directory.


That’s a very useful approach. Using your strategy, I found that both shell- and posixscript will point to the root folder if the path isn’t specified.

Thank you for your assistance!