Hello Everyone!
I am trying to restart Appium periodically. I have 2 simple scripts (startAppium.sh and stopAppium.sh) on the box hosting Appium. Here is what the startAppium.sh script looks like:
This works great when I try to run the script on the box itself. However, when I do it remotely through the following command:
ssh [email protected] /Users/qaadmin/startAppium.sh
I get the following error: "env: node: No such file or directory"
I am puzzled as if I first ssh to the box with the same user and execute the script, all works well. What am I missing?
You are looking at a permissions issue. Users are by default not allowed to look in each other’s home directories and execute scripts. You may also be looking at file permissions issues. Here’s what to do:
Put your executable into ‘/usr/local/bin’, and make sure that is on the $PATH (check by logging in as the user in question and issuing ‘echo $PATH’ on the command line). More info here:
Make sure your user has permission to execute the file. You could probably just do a ‘chmod +x /usr/local/bin/startAppium.sh’ on the command line. More info here:
I try to move the executable script and see if that solves the issue. Permissions are unlikely the culprit as I am able to execute the script when I first ssh with the same user and then execute the script (instead of doing both within the local script). Also, I have no issues remotely running stopAppium.sh that is in the same directory, with the same set of permissions. Here is the content of my stopAppium.sh: echo “Attempting to stop Appium if already running.” ps -ef | grep ‘appium.js’ | grep -v grep | awk ‘{print $2}’ | xargs kill
I figured it out. Looks like env variables are not loaded when I ssh to the remote host. I ended up adding node location to the startAppium.sh script and working fine now.