MacOS – How to add the parameters of the OSX LaunchD PLIST to the pipe output to the log file?

I have tried many different changes, but I can’t make it work.

I have a plist file:





Label< br /> com.ilium007.handbrake
ProgramArguments

/bin/bash< br /> /Users/ilium007/support/scripts/handbrake/handbrake.sh >> /Users/ilium007/support/scripts/handbrake/logs/handbrake_encode.log
>>-->


RunAtLoad

StartInterval
60

Please pay attention to the comments there.

I want to pipe the output of the handbrake.sh script to a log file and try to do so, but “No such file” keeps appearing in the system.log on OSX Error.

Nov 3 18:03:54 macmini com.ilium007.handbrake[15348]: /bin/bash: /Users/ilium007/support/scripts/handbrake/handbrake .sh >> /Users/ilium007/support/scripts/handbrake/logs/handbrake_encode.log: No such file or directory Nov 3 18:03:54 macmini com.apple.launchd.peruser.501[162] (com.ilium007 .handbrake[15348]): Exited with code: 127

If I change the plist to the following, it will run, but I have no record, so I assume it only runs the first parameter:





Label
com.ilium007.handbrake
ProgramArguments

/bin/bash
/Users/ilium007/support/scripts/handbrake/handbrake.sh
>>
/Users/ilium007/support/scripts/handbrake/logs/handbrake_encode.log

RunAtLoad

StartInterval
60

The command I want to run through launchd is:

/Users/ilium007/support/scripts/handbrake/handbrake.sh >> /Users/ilium007/support/scripts/handbrake/logs/handbrake_encode.log

There is nothing in the log file. But if I run the command from the terminal, I get the content in the log. Any Help, would be greatly appreciated.

>> is a shell operator, not a program parameter, and launchd will not pass its commands through the shell (unless you force it, as in @Lauri’s answer). But launchd does have its own option to redirect stdout:

< pre>StandardOutPath
/Users/ilium007/support/scripts/handbrake/logs/handbrake_encode.log

Please note that it will automatically Attach (equivalent to >> instead of >). You can also redirect stderr using the StandardErrorPath key. One thing you can’t do is use ~ (like ~/support/scripts/handbrake/logs/handbrake_encode.log) – this It is also a shell feature that launchd cannot simulate.

I have tried many different changes, but I can’t make it work.

I have a plist file:




< br /> Label
com.ilium007.handbrake
ProgramArguments

/bin/bash
/Users/ilium007/support/scripts/handbrake/handbrake.sh >> /Users/ilium007/support/scripts/handbrake/logs/handbrake_encode .log



RunAtLoad

StartInterval
60

< /pre>

Please pay attention to the comments there.

I want to pipe the output of the handbrake.sh script to a log file and try to do so, but it keeps appearing in the system.log on OSX "No such file" error.

Nov 3 18:03:54 macmini com.ilium007.handbrake[15348]: /bin/bash: /Users/ilium007/support/ scripts/handbrake/handbrake.sh >> /Users/ilium007/support/scripts/handbrake/logs/handbrake_encode.log: No such file or directory Nov 3 18:03:54 macmini com.apple.launchd.peruser.501[162 ] (com.ilium007.handbrake[15348]): Exited with code: 127

If I change the plist to the following, it will run, but I have no record, so I assume it only runs the first Parameters:





< key>Label
com.ilium007.handbrake
ProgramArguments

/ bin/bash
/Users/ilium007/support/scripts/handbrake/handbrake.sh
>>
/Users/ilium007/support/scripts/handbrake/logs/handbrake_encode.log

RunAtLoad

StartInterval
60

The command I want to run through launchd is:

/Users/ilium007/support/scripts/handbrake/handbrake.sh >> /Users/ilium007/support/scripts/handbrake/logs/handbrake_encode.log

There is nothing in the log file. But if I run the command from the terminal, I get the content in the log. Any Help, would be greatly appreciated.

>> is a shell operator, not a program parameter, and launchd will not pass its commands through the shell (unless you Force it, as in @Lauri's answer). But launchd does have its own option to redirect stdout:

StandardOutPath
/Users/ilium007/support/scripts/handbrake/logs/handbrake_encode.log

Please note that it will be appended automatically (equivalent to >>, not >). You can also use the StandardErrorPath key to redirect stderr. One thing you can't do is use ~ (such as ~/support/scripts/handbrake/logs/handbrake_encode.log)-this is also a shell feature that launchd cannot emulate.

Leave a Comment

Your email address will not be published.