Agreed! I sort of am - let me try to explain, may help.
Here is a snippet of my code => adding some debug output to a log file,
set "logFile="D:\plexServer\Plex Media Server\Scripts\plexPostProcessing.log""
echo Starting ... > %logfile%
echo Time = %time% %date% >> %logfile%
echo whoami, %username% >> %logfile%
echo username, %username% >> %logfile%
echo And, postProcessing ... %1 >> %logfile%
REM Find Windows Subsystem for Linux (wsl.exe), safe for Plex as 32 or 64 bit (and calling a 32 or 64 bit shell!). Try the default folder first
REM => More details at, https://stackoverflow.com/questions/70112271/why-is-the-wsl-command-not-found-by-cmd-on-starting-a-batch-file-with-a-double-c
REM Can use %SystemRoot%, or %windir%
if exist %SystemRoot%\System32\wsl.exe set "FileNameWSL=%SystemRoot%\System32\wsl.exe" & goto RunWSLCommands
if exist %SystemRoot%\Sysnative\wsl.exe set "FileNameWSL=%SystemRoot%\Sysnative\wsl.exe" & goto RunWSLCommands
REM Run my desired commands. %1 from Plex already includes double quotes ... so just pass %1, all good!
:RunWSLCommands
echo WSL: %FileNameWSL% >> %logfile%
echo Video File: %1 >> %logfile%
%FileNameWSL% /mnt/plexMedia/plexPostProcessing.sh %1
echo Done. >> %logfile%
If I manually run the script (CMD shell), plexPostProcessing.bat testFile, and then check the log file,
Starting ...
Time = 16:02:36.47 Tue 01/31/2023
whoami, micro
username, micro
And, postProcessing ... testFile
WSL: C:\WINDOWS\System32\wsl.exe
Video File: testFile
Done.
Now, on the WSL side, the code in the bash script,
echo "Starting wsl ..."
date
echo "$SHELL"
echo "Here ..." > /tmp/plexPostProcessing.log
date >> /tmp/plexPostProcessing.log
echo "$SHELL" >> /tmp/plexPostProcessing.log
echo $1 >> /tmp/plexPostProcessing.log
And, checking this, cat /tmp/plexPostProcessing.log,
Here ...
Tue Jan 31 16:02:36 CST 2023
/bin/bash
testFile
Yep, exactly as all expected. But then, try a recording from Plex, and the two log files … Windows,
Starting ...
Time = 16:05:26.28 Tue 01/31/2023
whoami, micro
username, micro
And, postProcessing ... "E:\plexArchive\TV Shows\.grab\02ff54d9796c1c184f11080618ba4dd68741d7cb-30ac5a226a4d374f329a8d841bd8aab7bd91d9c8\Family Feud (2010) - S20E136 - Family Feud.ts"
WSL: C:\WINDOWS\System32\wsl.exe
Video File: "E:\plexArchive\TV Shows\.grab\02ff54d9796c1c184f11080618ba4dd68741d7cb-30ac5a226a4d374f329a8d841bd8aab7bd91d9c8\Family Feud (2010) - S20E136 - Family Feud.ts"
Done.
Perfect! My script is being called. So then, on WSL,
Here ...
Tue Jan 31 16:02:36 CST 2023
/bin/bash
testFile
Nope
. Still the old contents. So only with Plex, I’m not getting over to WSL. Make sense?
Thanks!