tags:

views:

269

answers:

2

hi i want to execute bash script with ssh but when i try this it's using ksh to execute command because of user has default shell is ksh which i use with ssh

i can't change user default shell

so what trick can i do to execute my bash script with ssh ?

+2  A: 

You can call your script explicitly with bash:

ssh <ssh-opts> bash <scriptname>

This way there will be a ksh executed at login, but inside ksh you start a bash executing your script.

tangens
+4  A: 

Make this the first line of your script:

#!/usr/bin/env bash

Edit: As per this, the utility of /usr/bin/env is dubious. So, you probably want:

#!/bin/bash

Replace /bin/bash with the actual path of bash executable.

Alok
i added this line then it doesnt execute script :S
soField
@soField: Try with my edit, or try tangens method. You must make sure `bash` is installed on the server.
Alok
so it would be ssh user@host /bin/bash command.sh ? is it ok
soField
Do you know where bash is installed on the server? As tangens said, it would be `ssh user@host bash command.sh`. If you want to use my method, you need to make the first line `#!<path of bash>`, where you replace `<path of bash>` by the actual `bash` executable's full path: it could be `/bin/bash`, `/usr/bin/bash`, or something else.
Alok
i think the problem is my command has " character , it may cause a problem is there any way to execute command with ssh which contains " chars in it
soField
Why do you have a command with `"` in it? `ssh user@host 'com\"mand arg'` may work.
Alok