ssh-action: Some commands don't work
err: bash: -c: line 3: syntax error near unexpected token `('
2020/02/09 17:57:24 Process exited with status 1
err: bash: -c: line 3: `sudo rm -r /usr/dotnetapps/bugsincluded/!(*.db*)'
This is a valid linux command that removes all files and folders that don’t match the pattern, it works when I run it manually on my server, but it doesn’t work using this ssh-action tool.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 34 (10 by maintainers)
@MahbbRah
this issue is about interactive vs non interactive shell.
you can check this at: https://askubuntu.com/questions/247738/why-is-etc-profile-not-invoked-for-non-login-shells
basically, if you are running a command in a non interactive shell, like ssh-action, on many linux distros,
“/etc/bash.bashrc” file has a specific command that returns only, so some of the files didn’t run and some specific commands doesn’t add to path,
just comment out the line that returns early and everything should work fine, or you can use the real paths of the commands that you would like to use.
Thanks @kocyigityunus. Commenting the .bashrc line solved my issue. As my workflow runs nvm, yarn and docker scripts, that was the easiest way to handle
Along the same lines, does anyone have a solution for cd not working? thanks
Another approach is to put your command into the shell script file and execute
sh xxxx.sh
.See the document: https://github.com/appleboy/ssh-action#command-not-found-npm-or-other-command
I will update the README to address the @kocyigityunus solution.
The full path didn’t work for me, but I found a solution. I realized that if I run
echo $PATH
in in a normal SSH session, I get a longer$PATH
compared to what I get if I run the same command with the this GH Action workflow.Reason: interactive vs non-interactive shell see → https://github.com/appleboy/ssh-action/issues/31#issuecomment-1006565847
Solution for npm: https://github.com/appleboy/ssh-action/issues/21#issuecomment-574050424
General solution:
$PATH
when the action runs$PATH
directories to the thing you are trying to use will probably solve the issue.Hey Magesh, We actually moved to the ubuntu server. This worked fine on Ubuntu.
I’m having the same issue. SSH to Windows Server only runs a single comand @ShravaniRoy did you ever solve this?
Only the first command works from script:
Am I missing something?? @appleboy – thank you!!
you need to have the
steps
keyword @mittalyashuI think it will try to execute inside the vps you’re trying to ssh into. You could use
run
instead like thisI think that should work