[bash] running a function remotely using ssh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [bash] running a function remotely using ssh
# 8  
Old 02-16-2017
Chubler_XL, that's look promising, I already tried a similar thing, but it still output a problem.
I guess that there is something with bash version here
mine:
Code:
bash --version
GNU bash, version 3.2.51(1)-release (x86_64-suse-linux-gnu)

new output:
Code:
Unmatched ".
{: Command not found.
for: Command not found.
do: Command not found.
var: Undefined variable.
done: Command not found.

Unmatched ".




do u have a workaround for this?


btw, fixed my output in original post.

Last edited by rbatte1; 02-16-2017 at 07:09 AM.. Reason: Added CODE tags
# 9  
Old 02-16-2017
This works here also.

Code:
#!/bin/bash

function nu ()
{
        for var in {0..5}; do printf "$var, "; done; echo
}

ssh host /usr/bin/bash <<EOF
$(typeset -f)
nu
EOF

These 2 Users Gave Thanks to Chubler_XL For This Post:
# 10  
Old 02-16-2017
Linux

Quote:
Originally Posted by Chubler_XL
This works here also.

Code:
#!/bin/bash

function nu ()
{
        for var in {0..5}; do printf "$var, "; done; echo
}

ssh host /usr/bin/bash <<EOF
$(typeset -f)
nu
EOF



Genius!
Thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Then error while running script remotely

facing issue with then error while running a local script aginst a remote server. i facing the same issue in multiple scripts. So what i am missing here or what is needed. #!/bin/ksh echo "enter the filename" read file if then echo "file exists" else echo "file does not exists" fi ... (0 Replies)
Discussion started by: NarayanaPrakash
0 Replies

2. Solaris

SSH Remotely

Hello. I am trying to ssh and run a script from a remote computer. These computers will be both Windows and MACs. I am using Solaris 8 and what I have tried is: using putty ssh user@ip_address (remote command) /folder/folder/filename.sh The issue here is that the user profile has not... (3 Replies)
Discussion started by: jkmtm
3 Replies

3. Shell Programming and Scripting

remotely call function from local script

The following code doesn't work properly which means it doesn't displays remote output. #!/bin/ksh #################### Function macAddressFinder ######################## macAddressFinder() { `ifconfig -a > ipInterfaces` `cat ipInterfaces` }... (2 Replies)
Discussion started by: presul
2 Replies

4. Shell Programming and Scripting

howto run remotely call function from within script

Hi I have the following script : #!/bin/ksh #################### Function macAddressFinder ######################## macAddressFinder() { `ifconfig -a > ipInterfaces` `cat ipInterfaces` } ####################################################################### # # print... (2 Replies)
Discussion started by: presul
2 Replies

5. Shell Programming and Scripting

Running a function on a remote server via SSH in a script

I'm working on a script (mostly for practice) to simplify a task I have to do every now and then. I have a cluster with 6 servers on it, each server has a directory with a set of files called *.pid and *.mpid. Each file contains the pid of a process that may or may not be running on that server.... (3 Replies)
Discussion started by: DeCoTwc
3 Replies

6. AIX

Mozilla running remotely

We have a server that has CDE and Mozilla installed on it. I have a develpoer who want to have an application start Mozilla locally on the AIX server (which has no video card) or wants Mozilla running on the server at all times. Can anybody tell me if this is at all possible? If so how and if... (4 Replies)
Discussion started by: daveisme
4 Replies

7. Shell Programming and Scripting

ssh running on function

i have a problem regarding running an ssh command while inside "function" script structure #!/usr/bin/bash func1(){ script=$1 ssh user@server "$script" } cat script.txt | while read line do func1 $line done exit 0 the problem is when ssh ran,... (1 Reply)
Discussion started by: ryandegreat25
1 Replies

8. Shell Programming and Scripting

Run function from script over ssh (BASH)

Hi, Is there any cleaver way to run function from the bash scrip over ssh? For example: #!/bin/bash #Function 1 FN1 () { ls -l } #Main run ssh user@host FN1 exit 0 Yeah, I know it will not work, but I'm asking how to make it to work :) I'm suspecting that it would be... (1 Reply)
Discussion started by: columb
1 Replies

9. Shell Programming and Scripting

Running function or command concurrently in a bash script

I currently run a script over a vpnc tunnel to back-up my data to a remote server. However for a number of reasons the tunnel often collapses. If I manually restore the tunnel then the whole thing can continue, but I want to add into my script a section whereby while the transfer is taking place,... (8 Replies)
Discussion started by: dj_bridges
8 Replies

10. Shell Programming and Scripting

running commands with remotely with Telnet

i have a box here that can only be accessed with telnet. now, i was wondering if anyone know of a way of which i can run a command on that box remotely. (2 Replies)
Discussion started by: Terrible
2 Replies
Login or Register to Ask a Question