I have a deploy.sh file that I would like to run from my local macbook that will ssh into a remote Ubuntu 22 server and run a few commands there. Example here:
#!/opt/homebrew/bin/zsh
main() {
scp \
on_server.sh \
# other files \
"$remote_location:/correct/location"
ssh $remote_location "cd correct/location; echo $SHELL; ./on_server.sh"
}
main "$@"
The on_server.sh file has a couple commands using pnpm and pm2:
#!/usr/bin/zsh
pnpm i
pnpm build
pm2 restart app_name
If I ssh manually into my server, cd into the right place, and run those pnpm & pm2 commands everything is fine. When my deploy.sh does seemingly the same thing, I get errors that pnpm and pm2 commands are not defined.
However, I noticed that $SHELL is different between the two situations.
Manual ssh:
ssh <remote_location>
...
echo $SHELL
/usr/bin/zsh
The output of the echo $SHELL from on_server.sh above is:
/bin/zsh
I believe this $SHELL difference is why my commands are failing. Can someone help me understand why there is this difference in the $SHELL value?