Go Back   TechArena Community > Technology > Networking & Security
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



SSH return function

Networking & Security


Reply
 
Thread Tools Search this Thread
  #1  
Old 22-04-2010
Member
 
Join Date: Mar 2010
Posts: 197
SSH return function
  

Hello,
I have a problem with the return command. I have a function that is called function_1 in the hand. In this role, several places of return (if I get an error, I wish to exit this function without function_1 execute to the end). I would now relocate some treatments function_1 a new function, function_2, which will be called into function_1. My question is: if I made a return in function_2 is what I would leave also function_1 (behavior wishes). If not, how can I do? Any help regarding this topic will be helpful. Thanks in advance.

Reply With Quote
  #2  
Old 22-04-2010
Member
 
Join Date: Nov 2009
Posts: 343
Re: SSH return function

Hello,
A prior, if you made a return in fcnt_2, you come back in fcnt_1, you can decide to code a return value for fcnt_2 (genus return 1 if error, 0 otherwise), and test the return value in fcnt_1:
Code:
int ret = fcnt_2 (......);
if (ret == 1) (
     return (the function here) / * and you come back in main * /
else (
/ * S is smoothly fcnt_2 * /
.....
and you have tested every call fcnt_2, there may be simpler, but at least like this, you most effective way of testing your fcnt_2 function.
Reply With Quote
  #3  
Old 22-04-2010
Member
 
Join Date: Apr 2008
Posts: 264
Re: SSH return function

Hello,
I do have a similar kind of problem.
Here is what i am trying
Code:
func_1 ()
(
  command = "command shell has"
  func_2
 
  command = "Shell command b"
  func_2

  command = "c shell command"
  func_2

   ...
)

func_2 ()
(
  if! $ command; Then
    echo "$ command has failed."
    # -> This is where I put a "return" to exit the func_1 ...
  fi
)

# Main

func_1

...

Hand # end
Reply With Quote
  #4  
Old 22-04-2010
Member
 
Join Date: Nov 2009
Posts: 347
Re: SSH return function

Hello,
See if the following code can help you
Code:
#! / Bin / sh
func2 ()
(
        $ 1 | | (
                RET = $?
                echo "$ 1 was aborted"
                return $ RET
        )
)

func1 ()
(
        func2 echo success' | | return $?

        func2 'echoz "failure"' | | return $?

        func2 echo vanished '| | return $?
)

# A "hand" reduced to its simplest expression:
func1
Reply With Quote
  #5  
Old 22-04-2010
Member
 
Join Date: Nov 2009
Posts: 335
Re: SSH return function

Hello,
You can use the & & and | | for chaining of operations:
Here is what i am saying
Code:
command1 & & command2
command1 is executed, and if the result is zero, command2 is executed otherwise command2 is not.
Code:
command1 | | command2
Conversely, if command1 returns zero, command2 N'SET not executed.
Reply With Quote
  #6  
Old 22-04-2010
Member
 
Join Date: May 2008
Posts: 248
Re: SSH return function

Hello,
See if the following code is helpful to you
Code:
#! / Bin / sh
func_1 ()
(
  cd = "my_command '
  func_2 | | return
)

func_2 ()
(
  if! eval $ cd> / dev / null 2> &1; Then
    r = $?
    end_test "NO" "$ cd failed."
    odi_todo = 0
    return $ r
  else
    return 0
  fi
)

# Main
func_1
Reply With Quote
Reply

  TechArena Community > Technology > Networking & Security
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "SSH return function"
Thread Thread Starter Forum Replies Last Post
Is it possible for a function to return two values? hounds Software Development 5 13-03-2010 06:51 PM
How can I return different class in one function? Madaleno Software Development 4 10-02-2010 08:45 PM
Return string from a function in C Samarth Software Development 3 28-12-2009 11:24 AM
How to return an array from function Rilex Software Development 3 02-10-2009 09:18 AM
How to return a recordset from a function in ASP Ananias Software Development 3 19-06-2009 11:35 PM


All times are GMT +5.5. The time now is 01:44 PM.