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 7 years ago
- Reactions: 2
- Comments: 40 (10 by maintainers)
Links to this issue
- appleboy-ssh-action/README.md at master - appleboy-ssh-action - Gitea: Git with a cup of tea
- actions/appleboy-ssh-action: Mirror of https://github.com/appleboy/ssh-action - appleboy-ssh-action - Gitea: Git with a cup of tea
- athlonreg/ssh-action: GitHub Actions for executing remote ssh commands. - ssh-action - Gitea: Git with a cup of tea
- ssh-action/README.md at master - ssh-action - Gitea: Git with a cup of tea
- athlonreg/ssh-action: GitHub Actions for executing remote ssh commands. - ssh-action - Gitea: Git with a cup of tea
@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
The full path didn’t work for me, but I found a solution. I realized that if I run
echo $PATHin in a normal SSH session, I get a longer$PATHcompared 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:
$PATHwhen the action runs$PATHdirectories to the thing you are trying to use will probably solve the issue.I will update the README to address the @kocyigityunus solution.
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.thanks!!! it works for me
I have found a good solution, just add a line to your script, eg:
the /etc/profile is working for
ssh remote command user, refer to this articleSee the document: https://github.com/appleboy/ssh-action#command-not-found-npm-or-other-command
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
stepskeyword @mittalyashuI think it will try to execute inside the vps you’re trying to ssh into. You could use
runinstead like thisI think that should work