Get local variable from ssh call in shell

I have a script called which copies a shell script called on a remote machine.

scp host@user_a:remote_directory

Then i connect to that ssh host and execute it like this

ssh host@user "
                cd remote_directory

So far so good and everything is ok, the problem is that i want to get a local variable inside to I tried doing this

ssh host@user "
                cd remote_directory

But this does not work and the even the call of my local script does not work properly anymore. Any suggestions how can i overcome this issue.

PS : Copying the variable to a temporary file is not an option. I am looking for a shell solution for this if possible.


You are using a command substitution, which is necessary, but it is in the wrong place. You should place it around the entire SSH command:

my_var=$(ssh host@user "cd remote_directory; ./")

This is assuming that the variable you want to capture is being outputted by my_local_script eg by echo or printf.

Need Your Help

How to call a javascript function when iframe finished loading?

javascript html iframe

Could any one tell me how I can detect if an iframe has finished loading so I can call a javascript function and alert the user that iframe finished loading and do some other process inside the