howto run remotely call function from within script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting howto run remotely call function from within script
# 1  
Old 06-09-2010
howto run remotely call function from within script

Hi

I have the following script :
Code:
#!/bin/ksh
#################### Function macAddressFinder ########################
macAddressFinder()
{
  `ifconfig -a > ipInterfaces`
   `cat ipInterfaces`
}
#######################################################################



#
#
  
print -n "Server name is: "
read ServerName
     
     ssh $LOGNAME@$ServerName "$(macAddressFinder)"

exit

When I execute this script I receive output from function macAddressFinder only from the machine where I executed this script. It doesn't give me back data from remote machine.

Last edited by presul; 06-09-2010 at 08:34 PM..
# 2  
Old 06-09-2010
You should use "Command"

Hello~ Smilie

I think you should use only "Command" with ssh.

So if you want to call function, it is better to make a script.
For example...

1) yourcommand.sh
---> ssh $LOGNAME@$ServerName "/tmp/function.sh"

2) /tmp/function.sh
---> ifconfig -a > ifInterfaces
---> cat ifInterfaces

.... It works well. Thank you~. Smilie
# 3  
Old 06-09-2010
Yes this solution I allready figured out. I was wondering is there a way to do it without file with function definition ?
Maybe through some interface like in object oriented programming ?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Shell Programming and Scripting

Call function as different user within the script

Hello For HP-UX, ksh shell, is it possible to define functions and call them by another user ? For example <function_name> ( ) { command1 command2 } su - <user> -c <function_name> Or the only option is defining the user in the function itself as follows - <function_name> ( )... (2 Replies)
Discussion started by: atanubanerji
2 Replies

3. Shell Programming and Scripting

Run yes/no script remotely

I have this script in server2 # cat /root/yesno.sh #!/bin/bash read -p "are you sure?" -n 1 -r if $ ]]; then echo "" echo "YES" else echo "NO" fi # sh /root/yesno.sh are you sure?y YES (5 Replies)
Discussion started by: anil510
5 Replies

4. Shell Programming and Scripting

Call function from another script

Hey, i got this 2 file. When i try to pick option 1, which is test1, it says ./test: test1: not found. Any idea on how i can fix it? #!/bin/sh QUIT=0 `dirname $0`/testfile while ; do testmenu read option case $option in 1) test1 ;; 2) test2 ;; 3) echo... (2 Replies)
Discussion started by: Nick1097
2 Replies

5. Shell Programming and Scripting

Script – Function Call

Hello, I have Individual function in my shell script , Function1 { Master activities } Function2 { Sub activities 1 } Function3 { Sub activities 2 } … (2 Replies)
Discussion started by: Shanks
2 Replies

6. 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

7. Shell Programming and Scripting

Shell Script to call another function

Here is the following code : 1. # gcc -c test firstprog.c the above command will generate a executable file called "test " in which ever directory it is run. Assuming It will also return a value. 2. In the below SCRIPT . test is a file generated by compiling a c program... (3 Replies)
Discussion started by: Vabiosis
3 Replies

8. Shell Programming and Scripting

Need help howto make a script for Set SNOOP run for 5 minutes

Hi all, I want to monitoring my interface every 6 hours where i want to run snoop command to capture all packet through the interface, so i want running snoop then snoop will run for 5 minutes after that snoop stop then will start again after 6 hours than run for 5 minutes again. thereis any... (9 Replies)
Discussion started by: tindasz
9 Replies

9. Shell Programming and Scripting

how can i call a function in shell script

i have a function written in one shell script and i want to call that function in another shell script and use the value returned by that script. can any one suggest me how can i do that? regards, Rajesh.P (4 Replies)
Discussion started by: rajesh.P
4 Replies
Login or Register to Ask a Question