July 30, 2019 at 17:30 #23100
In the server.cfg there is the option to run scripts at various times before, during, after the NoMachine session.
I have a script that is tested and sucessfully working from the terminal (file is deleted from folder upon execution), however when I add the script to the server.cfg and try to use any of the scenarios (e.g. UserScriptAfterLogout) the expected behavior does not occur as the script does not seem to execute.
I have checked all the file/folder permissions and these appear to be okay.
What am I doing wrong?
PS – The script is located in a hidden folder, does this make any difference?July 31, 2019 at 15:03 #23111
First thing to check is if script is executable and user “nx” has permissions to run it. Than check if you correctly set your script into server.cfg e.g:
UserScriptAfterSessionStart = "/usr/NX/scripts/custom/myScript.sh"
Do you log in straight onto the machine where you edit server.cfg? You can find more information about custom scripts on this link : https://www.nomachine.com/DT02O00125#11.3.
If everything looks ok than we’d need to take a look at logs. To do it please uncomment and set the ‘SessionLogLevel 7’ configuration key in the ‘/usr/NX/etc/server.cfg’ than reproduce problem i.e in your case e.g set
UserScriptAfterLogin = "/usr/NX/scripts/custom/myScript.sh"then connect with NoMachine client and log in.
Here you can find detailed info on how to gather logs: https://www.nomachine.com/DT10O00163.August 1, 2019 at 07:30 #23123
check if script is executable and user “nx” has permissions to run it. Than check if you correctly set your script into server.cfg
Yes user “nx” has read&write permissions and script is correctly referenced in server.cfg. I also used sudo chmod +x myscript.sh to make it executable.
Even further than this, I set chmod 777 permissions on the script so anyone could run, but this did not seem to make any difference either.
Do you log in straight onto the machine where you edit server.cfg?
I am trying to add the same custom script to: UserScriptAfterLogout, UserScriptAfterSessionClose, UserScriptAfterSessionFailure.
However, I began by adding it only to: UserScriptAfterLogout as this seemed to be the most common event recorded in the logs (user disconnects from NoMachine server by pressing close, NoMachine records this in logs as ‘User Logoff’ and this is when I want the script to execute).
Whether adding to one at a time, or to all 3 however, it doesn’t work with any of them.
I have recorded a log at SessionLogLevel 7, my issue you will see is with UserScriptAfterLogout.
I have attached the log to this message.August 1, 2019 at 13:57 #23136
Can you submit those logs to forum[at]nomachine[dot]com, making sure you put the topic title as the subject of your mail. Thanks!August 2, 2019 at 15:27 #23155
Logfile sent to the email address.August 5, 2019 at 10:25 #23170
Hello, looks like there’s some problem in your script:
2019-07-31 19:54:27 347.045 1139 NXSERVER WARNING! Process ‘/Library/Scripts/cleanup.sh main 192.168.0.77’ with pid ‘1216/1216’ finished with exit code 2 after 0,006 seconds.
nxerror.log might show some more info. Script will probably fail even if you run it by hand. if you’re unable to fix it, you can post your script here and we could take a look at it.August 6, 2019 at 18:45 #23214
Script is working okay when run manually.
Both in terminal and when called by a preceding sh to run it.
Will look at nxerror.log to see if it tells me anything else and email it also if I can’t get any further.
You must be logged in to reply to this topic.