[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need help for bash function return value

From: Greg Wooledge
Subject: Re: Need help for bash function return value
Date: Mon, 15 Oct 2012 08:56:12 -0400
User-agent: Mutt/

On Mon, Oct 15, 2012 at 10:04:39AM +0800, Tinni wrote:
> Thank you so much  for your reply and  explanation.
> >>So, you're trying to retrieve 3 separate (string?) values from a remote
> system.
> Yes.
> >> Why not simply prompt the user for the
> information on the local system and skip the ssh call altogether?
> Because  the script  has to run  in  database  servers.. 
> In your explanation , if I understand correctly, it will take the parameter
> value from test1.sh in the remote server  and returned to the local server 
> right?
> >>source ~oracle/.whatever || exit
> Can I use  source ~test1/test1.sh  to call into remote  server?

If test1.sh is the one that has the embedded terminal escape sequences
and the prompts and the read commands, then you're not going to be able
to use it in this way.  All of the output it produces (the prompts and
the terminal escape sequences and the labels and status indicators and
so on) will contaminate the data stream that you're sending back to the
local system.  The interactive "read" commands will attempt to pull data
from stdin, but in my example I was using stdin to send the commands
to the remote bash shell, so you can't use it to read from the user's

If you truly need to prompt the user for information and then use that
information to communicate with a database to get DIFFERENT information,
all of it across an ssh session, then you have a monstrous set of problems
to solve.

>  -  To execute the script , first  I have created  /lhome/test1/.test in the 
> remote server assigning
>      the  value  in each parameter. But no  values  returned into the local 
> server.
>  -  Then  I used  /lhome/test1/test1.sh [  which was  my original script in 
> remote ] ,, but  it 
>     did not wait for value to type , and as a result  no value returned into 
> the local server..
> Am I doing anything wrong?

If it's not working then obviously you're doing something wrong.  This
problem is so difficult to solve that it's going to take you a much
greater effort than I think you were expecting.

> As I mentioned in my original email, that i need to execute the test1.sh 
> script in the remote server
> and process, then the value i need in the local server for further process. 

But the test1.sh script is *not suitable* for this problem.  You need to
find another way to get the information, without using test1.sh.  Take
it apart, see what it does, and then see how you can perform those same
steps without all the noise and interaction.

> If my approach  is not right, then would you please suggest , in this 
> situation, what kind of
> approach I need to take to write the script!!

Start by specifying exactly what results you need.  Always keep this end
goal in mind.

Next, understand the working environment.  You're trying to retrieve
data from a remote system accessible with ssh, which is very different
from a system where you have an interactive terminal with a shell in
it, or a graphical interface.  There are limitations in the ssh session
that I don't think you've fully come to terms with yet.  You may not be
able to use the tools you're accustomed to using (such as terminal-based
interactive shell scripts like "test1.sh") because they may not perform
correctly in the environment you're working under.

Then the final step is to figure out how to get the results you need in
your working environment.  This will require the proper selection and
use of many different tools.  You'll have to bring several techniques
together in precisely the right way.

I suggest that the proper venue for continuing this discussion is the
address@hidden mailing list, rather than bug-bash or private email.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]