|
| ||||||||||
| Tags: linux, networking, operating system, protocol, return function, ssh |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| SSH return function
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. |
|
#2
| |||
| |||
| 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 * /
..... |
|
#3
| ||||
| ||||
| 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 |
|
#4
| |||
| |||
| 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 |
|
#5
| |||
| |||
| Re: SSH return function
Hello, You can use the & & and | | for chaining of operations: Here is what i am saying Code: command1 & & command2 Code: command1 | | command2 |
|
#6
| ||||
| ||||
| 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 |
![]() |
|
| Thread Tools | Search this Thread |
| |
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 |