Scope issue: Trying to set the value of a variable in a calling (upper) script from a called (lower) script

Hi,
I have a basic scope question . I have two .ksh scripts. One calls the other.
I have a variable I define in script_one.ksh called var1.
I set it equal to 1. so export var1=1
I then call script_two,ksh from script_one.ksh.  In script_two.ksh I set the value of var1 to 2 . so var1=2.
I return to script_one.ksh and echo out var1 and it still is equal to 1.
How can I change the value of var1 in script_two.ksh to 2 and have that change reflected in script_one.ksh when I echo var1 out after returning from script_two.ksh.
I've remember seeing this I just can't remember how to do it.
Thanks in advance.

Unfortunately Unix or Linux does not have a concept of dynamic system kernel or global variables.
Environment variables can be exported from a parent to a child processes, similar to copying, but a child process cannot change the shell environment of its parent process.
However, there are a few ways you could use: You can source execute the scripts, using the Bash source command or by typing . space filename. When source executing a script, the content of the script are run in the current shell, similar to typing the commands at the command prompt.
Use shell functions instead of forking shell scripts.
Store the output of a script into a variable. For instance:
#test1.sh
var=goodbye
echo $var
#test2.sh
var=hello
echo $var
var=`./test1.sh`
echo $var
$ ./test2.sh
hello
goodbye

Similar Messages

  • How to set the value of a variable in a cluster in LabVIEW from C#?

    Hi guys, I'm working on a small c# program, which using the interface provided by LabVIEW.  And I know that, using lv.SetControlValue(name, value) can set a variable just on the front panel. But in my case, there're several clusters on the front panel. So it confused me how to set the variables in these clusters. For example there's a cluster named clusterA, and a variable in it named valueA, I've tried something like this:
    lv.SetControlValue("clusterA.valueA",1);
    but it totally not work. Anyone has some experience about this stuff? Thanks a lot!!
    Solved!
    Go to Solution.

    Hey guys, thanks a lot for all your reply. I just find a simply way to solve this porblem. For example, there a cluster named "ClusterA", and there are only two control values in it, which are: an int value named "IntA" (default value IntA = 10)and a  string value named "StringA" (default value StringA = "abc"). In C# if you invoke the method:
    var clusterA = (Array) vi.GetControlValue("ClusterA");
    you will get an Array looks like: clusterA = {10, "abc"}; Then if you want to change IntA to 123, you just need to do:
    clusterA.SetValue(123, 0); // 123 is the value, 0 is the index of IntA in the array clusterA, after this clusterA = {123, "abc"}
    After this, you just need to give the array back to LabVIEW by using:
    vi.SetControlValue("ClusterA", clusterA);
    and now see the panel in you LabVIEW, the IntA is changed.

  • I'm trying to set the value of a textfield to a instance of another textfield in a repeating subform

    Hello all,
    I am trying set the value of a textfield in a repeating subform/table row to another textfield in a repeating subform with the corrosponding instance number.
    The user enters a list of Key Activities in the first part: -- KeyActivityRow is the repeating subform --
    xfa.resolveNode("form1.#subform.KeyActivities.Row1.Table2.KeyActivityRow.Cell2")
    -- KeyActivityRow is the repeating subform --
    Which then Populates the corresponding occurence of:  --
    xfa.resolveNode("form1.#subform.ActivityTable.HeaderRow.Table1.HeaderRow.Cell1")
    -- ActivityTable is the repeating subform --
    Kevin

    In the calculate event of form1.#subform.ActivityTable.HeaderRow.Table1.HeaderR ow.Cell1 enter this script in Language:JavaScript :
    this.rawValue=xfa.resolveNode("form1.#subform.KeyActivities.Row1.Table2.KeyActivityRow["+A ctivityTable.index+"].Cell2").rawValue
    Kyle

  • How to set the value of process variables/payload using a managed bean?

    Hello,
    Someone can give me an example about how to set the values of a process payload in a managed bean?
    thank you!

    Try this:
    jsf page:
    <af:selectOneChoice label="Select Suburb"
    requiredMessageDetail="Select a suburb"
    valueChangeListener="#{selectOneChoiceBean.onValueChanged}"
    validator="#{selectOneChoiceBean.validate}"
    unselectedLabel="None" autoSubmit="true"
    binding="#{selectOneChoiceBean.selectOneChoice}"
    value="#{selectOneChoiceBean.value}">
    <f:selectItems value="#{selectOneChoiceBean.selectionList}"/>
    </af:selectOneChoice>
    backing bean:
    public class SelectChoiceBean {
    private List<SelectItem> selectionList;
    private String value = "B";
    private RichSelectOneChoice selectOneChoice;
    public SelectChoiceBean() {
    initSelectionList();
    public void setSelectionList(List<SelectItem> selectionList) {
    this.selectionList = selectionList;
    public List<SelectItem> getSelectionList() {
    return selectionList;
    public void onValueChanged(ValueChangeEvent valueChangeEvent) {
    System.out.println(valueChangeEvent.getNewValue());
    // Add event code here...
    public void validate(FacesContext facesContext, UIComponent uIComponent,
    Object object) {
    // Add event code here...
    private void initSelectionList() {
    selectionList = new ArrayList<SelectItem>();
    selectionList.add(new SelectItem("A", "A label"));
    selectionList.add(new SelectItem("B", "B label"));
    selectionList.add(new SelectItem("C", "C label"));
    public void setValue(String value) {
    this.value = value;
    public String getValue() {
    return value;
    public void setSelectOneChoice(RichSelectOneChoice selectOneChoice) {
    this.selectOneChoice = selectOneChoice;
    public RichSelectOneChoice getSelectOneChoice() {
    return selectOneChoice;
    }

  • Can we set the value of repository variable if we invoke bi publisher

    report from Java. The parameter report is built in java they will pass all the parameters and based on the filter critirea
    bi publisher report will be generated

    Hi, this may not be relavent for you but, as I see you are working with BI pub and OBIEE I thought to share my issue.
    We have set up OBIEE and BI Pub. When I create a Answer without any prompts it works fine in BI pub and create a template. But, when I have a Answer with prompts and use the same Answer in BI pub, it throws an error and I cannot proceed to create templates.
    We did open a SR with metalink (oracle) but they say its the behaviour of BI pub/OBIEE. They want us to create a BI pub report and use the same in OBIEE, which is not what we are looking for.
    Anyways, this is just an FYI.
    Thanks,
    Vijay

  • Can we set the value of repository variable in bi publisher as we do in

    dashboard prompt.. and if yes then how

    Hi, this may not be relavent for you but, as I see you are working with BI pub and OBIEE I thought to share my issue.
    We have set up OBIEE and BI Pub. When I create a Answer without any prompts it works fine in BI pub and create a template. But, when I have a Answer with prompts and use the same Answer in BI pub, it throws an error and I cannot proceed to create templates.
    We did open a SR with metalink (oracle) but they say its the behaviour of BI pub/OBIEE. They want us to create a BI pub report and use the same in OBIEE, which is not what we are looking for.
    Anyways, this is just an FYI.
    Thanks,
    Vijay

  • Not able to set the value in marketing context node for BP_HEAD

    Hi,
    I am trying to set the value in marketing node of BP_HEAD from bp_addr component. i am calling the set_property method but it is not changing the value, when i debugg the code, it actually changing the value in bol structure but it is not calling the get/set method of bp head.
    i am working on BP corporate person  creation i.e. in bp_head component and account details view. I added the marketing attributes in UI configuration and also the address attributes.
    this is what i coded in get method of country in standardaddress context node of BP_ADDR
    lv_entity ?= current.
        IF lv_entity IS BOUND.
          lv_parent = lv_entity->get_parent( ).
          IF lv_parent IS BOUND.
            lv_entity_mkt = lv_parent->get_related_entity( iv_relation_name = 'BuilMarketingRel' ).
            IF lv_entity_mkt IS BOUND.
              CALL METHOD lv_entity_mkt->set_property
                EXPORTING
                  iv_attr_name = 'ATTRIBUTE'
                  iv_value     = attribute1.
    Can anyone please guide me on how to set the value cross component and can we call the get/set method of that attribute which is not in same component?
    Regards,
    Kamesh Bathla

    Sorry, what I said was rubbish, because the LSMW and the session run in different external sessions.
    I have searched forum for these terms: "company BUK parameter BDC background"
    These threads Is it possible to set default company code in SM35? and Release BDC in SM35 in background, How to set defaul company code? seem promising, but I'm not sure they really solve.
    In case these threads don't help you, I think you can create your own Z transaction which sets the BUK parameter id and then does a LEAVE TO TRANSACTION 'ABAON'. Then create again the recording on the Z transaction.
    If you are using ECC6, then you may also enhance the standard to reset BUK parameter id at the very beginning of ABAON, in case it's run in batch input (sy-binpt = 'X'). Be careful as sometimes SAP does batch input on some transactions, so that could make the standard fail.
    Last thing, you can contact SAP support, though it might probably be considered as consulting.

  • Setting the value of a field based on a dropdown list

    I am using the latest production release of JHeadstart 10.1.3.0.91. I am trying to set the value of a field based on selecting the value of another field (drop down list). The drop down list field has the following attributes set autoSubmit="true" immediate="true" valueChangeListener="#{jhsPageLifecycle.updateModelValue}".
    The other field has the partialtrigger set to the first field. ie "depends on" selection from JHeadStart file. The value of the second field is set in the setter of the VO RowImpl java file.
    The value of that field is only populated on the screen if it is set to disabled="true". This seems a bit bizzare behaviour. Can you explain why it cannot set the value of the field when it is not disabled.

    Worked out that if i set the "Clear/Refresh value" attribute on the field that i want updated then it will work ok
    Alan

  • How to set the value in SelectManyChoice

    Hi,
    My problem is i m trying to set the value which is coming from the Iterator in select may choice as:
    DCIteratorBinding viewReportIter = getBindingsForDCB().findIteratorBinding("SelectedSQIRSuppliersVO1Iterator");
    ArrayList list = new ArrayList();
    Row datRow = viewReportIter.getRowAtRangeIndex(0);
    programDesc = datRow.getAttribute(1).toString();
    list.add(programDesc);
    suppliers.setValue(list.toString());
    but is is not set the value.
    Is there any other method to set the value.
    Thanks,
    Neha

    Passing array in selectedindices
    To select default value as ALL the following code is used .
    int rowCount = (int)vo.getEstimatedRowCount();
    stateIndex =new int[rowCount];
    for(int i=0;i<rowCount;i++){
    stateIndex[i] = i;
    BindingContext bctx = BindingContext.getCurrent();
    BindingContainer bindings = bctx.getCurrentBindingsEntry();
    JUCtrlListBinding list=(JUCtrlListBinding) bindings.get("ViewObject");
    list.setSelectedIndices(stateIndex);
    To select default value other than all .
    BindingContext bctx = BindingContext.getCurrent();
    BindingContainer bindings = bctx.getCurrentBindingsEntry();
    JUCtrlListBinding list=(JUCtrlListBinding) bindings.get("ViewObject");
    list.setSelectedIndex(arg0);
    arg0 - The row which you want to set checked by default

  • Setting the value of rich inputtext in jdeveloper 11g 11.1.2.3.0

    Hi,
    I am trying to set the value of input text in my .jspx page to the value of a command link. On the click of the link the value of the link needs to be displayed in the input text without having to type it.
    I have created an action method for the command link where I get the value from the command link and set it in the input text. I see in my log it is getting the current row from the command link but nothing is being set in the input text. Following is my code for the command link action method:
    This is where I am getting the value from the command link:
                    DCControlBinding cb;
                    cb = (DCControlBinding) bindings.get("ALL_DETAILS_ITEM");
                     System.out.println("cb  " + cb);
                    Row currentRow;
                    currentRow = cb.getCurrentRow();
                    System.out.println("currentRow " + currentRow);
                    String EMAIL_ADDRESS = null;
                    if ((currentRow.getAttribute("EMAIL_ADDRESS"))!= null)       
                       EMAIL_ADDRESS = (currentRow.getAttribute("EMAIL_ADDRESS")).toString();
                       System.out.println(" EMAIL_ADDRESS " +  EMAIL_ADDRESS);                                       
                           }This is where I am trying to set the input text value(P_EMAIL_ADDRESS) to the command link value(EMAIL_ADDRESS)
                        Map params = operationBinding.getParamsMap();
                        String P_EMAIL_ADDRESS = null;
                    if ((currentRow.getAttribute("P_EMAIL_ADDRESS"))== null)       
                        currentRow.setAttribute("P_EMAIL_ADDRESS", EMAIL_ADDRESS );
                         System.out.println("P_EMAIL_ADDRESS " + P_EMAIL_ADDRESS);                                       
                           params.put("P_EMAIL_ADDRESS", P_EMAIL_ADDRESS);
                           params.put("DISPLAY_TYPE", DISPLAY_TYPE);
                           Object result = operationBinding.execute();
                }I also have set a partial trigger of the input text to the command link Id in the UI.
    Any help would be appreciated.
    Thanks in advance,
    Sal

    This is overly complicated. you post the code of you command link?
    should work without any java code by setting a property listener which the from value set to the value of the link and the to property to the of the input text.
    Timo

  • Can not set the value attribute of a ContextNode

    Hi,
       I am trying to set the value Attribute in a value Node it is a simple way but it gives me java.lang.NullPointerException error on the given line:
    wdcontext.current(ValueNodeName)Element.set(AttributeValueName)
    Thanks in advance
    Best Regards
    Beata

    Like all above suggested do this:
    wdContext.node(ValueNodeName).add(
               wdContext.node(ValueNodeName).create(ValueNode)Element()
    wdContext.node(ValueNodeName).moveLast();
    wdContext.current(ValueNode)Element().setATTR(..);

  • Can you change the value of a variable that is reset by a parameter?

    Sorry if this is simple but I just crashed a package and can't do an autopsy. I suspect I sent it into an infinite loop. I know you can't change the value of any passed in parameters. What I tried to do was have the parameter set the value of a variable
    and then I tried to change the value of the variable. Is that even allowed?
    I was trying to do this:
    MyCheckVariable = MyParameter (which equals true)
    (some cool stuff happens)
    MyCheckVariable = False
    I hit F5 and my package turned into the Energizer Bunny. Is the way I try to reset the variable the culprit?

    This is a prototype so I just created a project parameter and set it to true. In the real world the parameter will be used to control an optional part of the process because on a re-run after error that part doesn't have to be ran again.
    So when I say MyCheckVariable = MyParameter (which equals true) in reality what I actually have is in the variables window I'm using an expression and it looks like this in the variables window
    name = runDownload
    Scope = Package
    Data Type = Boolean
    Value = True (but greyed out)
    Expression = @[$Project::param_runDownload]

  • Setting the value of a single attribute for multiple line items

    Hi all,
    I am working on a Web Dynpro application, I have created this applicaion for an accounting document so it has header data and multiple line item data. As per the requirement I have to put the following logic:
    1. When a user enters a value in the field KBLNR on the line item, all the other fields like cost centerm fund, functional area should populate from a database table based on the value of the KBLNR. to get this I have put the following code:
    TYPES: BEGIN OF t_kblp,
              fipos     TYPE kblp-fipos,
              kostl     TYPE kostl,
                      END OF t_kblp.
      DATA lv_kblnr TYPE wd_this->element_t_bseg-kblnr.
      DATA: lt_kblp TYPE STANDARD TABLE OF t_kblp,
            wa_kblp LIKE LINE OF lt_kblp,
            lt_bseg              TYPE STANDARD TABLE OF bseg,
            wa_bseg              TYPE bseg.
      DATA lo_nd_t_bseg TYPE REF TO if_wd_context_node.
      DATA lo_el_t_bseg TYPE REF TO if_wd_context_element.
      DATA: ls_t_bseg TYPE wd_this->element_t_bseg,
            lo_api_controller    TYPE REF TO if_wd_controller,
            lo_message_manager   TYPE REF TO if_wd_message_manager,
            lo_nd_tbseg          TYPE REF TO if_wd_context_node,
             lo_el_tbseg          TYPE REF TO if_wd_context_element,
             lt_el_tbseg          TYPE wdr_context_element_set,
             lv_bseg              TYPE bseg.
      lo_nd_t_bseg = wd_context->path_get_node( path = `ZDATA.CHANGING.T_BSEG` ).
      lo_api_controller ?= wd_this->wd_get_api( ).
      CALL METHOD lo_api_controller->get_message_manager
        RECEIVING
          message_manager = lo_message_manager.
      lo_nd_tbseg = wd_context->path_get_node( path = `ZDATA.CHANGING.T_BSEG` ).
      lt_el_tbseg = lo_nd_tbseg->get_elements( ).
      LOOP AT lt_el_tbseg INTO lo_el_tbseg.
        lo_el_tbseg->get_static_attributes(
                               IMPORTING static_attributes = lv_bseg ).
      IF lv_bseg-kblnr NE ' '.
          SELECT belnr
                 fipos
                 kostl
                 PSPNR
                 geber
                 saknr
                 fkber
                 grant_nbr
                 gsber
                 FROM kblp
                 inTO corresponding fields of wa_kblp
                 WHERE belnr = lv_bseg-kblnr and
                      saknr = lv_bseg-saknr.
            ENDSELECT.
    lo_nd_t_bseg = wd_context->path_get_node( path = `ZPRELIMINARY_POSTING.CHANGING.T_BSEG` ).
    * get element via lead selection
            lo_el_t_bseg = lo_nd_t_bseg->get_element( ).
    lo_el_tbseg->set_static_attributes(
                               EXPORTING static_attributes = wa_kblp ).
       CLEAR: lv_bseg, wa_kblp.
      ENDLOOP.
    everything is working fine but now the problem is couple of fields that I have in wa_kblp are with different names in bseg table and hence they are not updating... I tried putting the following logic within the loop :
    lo_el_t_bseg->set_attribute(
        name =  `PROJK`
    value = wa_kblp-pspnr ).
    but it's only setting the value of the first line item and not working for the multiple line items, can you please tell me how can do this?
    Thanks,
    Rajat Garg
    Edited by: rajatg on Jun 24, 2011 5:09 PM

    Hi Chris,
    I tried your code and it worked fine but after I put this code I am getting another issue. within the loop I had a code to make the fields non modifiable on the screen and was working fine but now what's happening is it's making the all the lines uneditable except the one with data on it (which is completely opposite), this is what I have coded:
    LOOP AT lt_el_tbseg INTO lo_el_tbseg.
        lo_el_tbseg->get_static_attributes(
                               IMPORTING static_attributes = lv_bseg ).
    IF lv_bseg-kblnr NE ' '.
      SELECT belnr
                 fipos
                 kostl
                 PSPNR
                 geber
                 saknr
                 fkber
                 grant_nbr
                 gsber
                 FROM kblp
                 inTO corresponding fields of wa_kblp
                 WHERE belnr = lv_bseg-kblnr and
                      saknr = lv_bseg-saknr.
            ENDSELECT.
    move: wa_kblp-belnr to wa_bseg-kblnr,
    wa_kblp-fipos to wa_bseg-fipos,
    wa_kblp-kostl to wa_bseg-kostl,
    wa_kblp-pspnr to wa_bseg-projk,
    wa_kblp-geber to wa_bseg-geber,
    wa_kblp-saknr to wa_bseg-saknr,
    wa_kblp-fkber to wa_bseg-fkber,
    wa_kblp-grant_nbr to wa_bseg-grant_nbr,
    wa_kblp-gsber to wa_bseg-gsber,
    lv_bseg-dmbtr to wa_bseg-dmbtr.
    append wa_bseg to lt_bseg.
    lo_nd_edit_property = wd_context->path_get_node( path = `ZPRELIMINARY_POSTING.CHANGING.T_BSEG.EDIT_PROPERTY` ).
          get element via lead selection
          lo_el_edit_property = lo_nd_edit_property->get_element( ).
          lo_el_edit_property->set_attribute(
            name =  `EDIT_FIELD`
            value = 'ABAP_TRUE' ).
          lo_el_edit_property->set_attribute(
            name =  `EDIT_WBS`
            value = 'ABAP_TRUE' ).
    endif.
    endloop.
    o_nd_t_bseg = wd_context->path_get_node( path = `ZPRELIMINARY_POSTING.CHANGING.T_BSEG` ).
    get element via lead selection
            lo_el_t_bseg = lo_nd_t_bseg->get_element( ).
      CALL METHOD lo_nd_t_bseg->bind_table
        EXPORTING
          new_items            = lt_bseg.
    Can you please see what I am doing it wrong here....

  • How to prevent numericstepper from setting the value to the defined Maximum when a number greater than maximum is entered in by keyboard and user hits the "Enter" key.

    I need to set the Maximum so that the use can use the mouse to change the value of numericstepper (and not go over a certain number), but at the same time I have to allow the user to enter their value by typing in the text field. When the user enters a number greater than the Maximum, I disable the "Ok" button of the dialog and show a red warning(error message). The issue is that the user can hit "Enter" and numeric stepper would set the value to the Maximum and the dialog box would close and the rest of code would run. I want the numericstepper not to change the value and keep showing the warning even if the user hits the "Enter".
    Note: Setting maxChar does not help since my maximum is 1000, and user might enter 5555
    I would appreciate the help.

    Thanks for trying to help, But
    The issue is that if I set the maximum value of stepper 1 greater than the max value that I want, then the user can select an invalid value(of myMax + 1) when he clicks on the UP arrow of the numeric stepper(which is not acceptable for what I am working on).
    I need to preserve the users invalid number, while not letting the user to select an invalid number by clicking UP key.
    I noticed that when the user enters a number greater than the Maximum, and then click on the down arrow, it would set the value to 1 less than the maximum. This is not acceptable either.

  • Set the value of a CWNumEdit Control from within the code

    I am trying to update a CWNumEdit Control with data created during program execution.  I am using the set_Text function but it does not seem to be working.  I was wondering if there is something that I am missing to get this functionality to work.  Please help.
    I am developing a VS .NET 2003 WinForm GUI and am Using Measurement Studio 8.1.1.

    Hello mtd32610,
    I noticed this question was already posted on this forum.  We like to
    keep all questions related to a single issue confined to one forum, so
    please direct all future replies to one post or the other.
    As Jervin_J mentioned in the previous post, the standard method for
    updating a CWNumEdit control is to set the Value property of the
    CNiNumEdit object that is associated with this control.  You do not
    need to call the set_Text function, in fact I am not familiar with any
    set_Text function, so I think you may be calling this method on the
    wrong class altogether.
    You should have an object associated with your CWNumEdit control that
    you can set the Value property for.  As mentioned in the reply from
    Jervin_J, the normal way to populate the control is to use:
    <control>.Value = <numeric_value>;
    Regards,
    Marty H.
    National Instruments

Maybe you are looking for

  • How to create hyperlink on one word inside a paragraph?

    I have a paragraph of text coming from the database as a CLOB, and I need to add a hyperlink to one word in the paragraph. I have done this for an entire field, but not one word inside the paragraph. Any ideas on how to do this? The output file is a

  • Is the battery the same for Satellite A200-1TG, -1TB, -1HU, ecc.?

    Hello. I'm going to buy a new battery for a Satellite A200-1TG, but it seems hard to get on-line a battery that has this specific model in its compatibility list. For example, this one: http://www.ravpower.com/ravpower-ts6a-rb-battery.html is written

  • How to sync phone and photos to recover 2k lost pictures

    i dont know exactly if i deleted all of my pictures or if they vanished with my last update... hard to say but i had about 2400 pictures... they are however on my iphone and im curious to see if i sync my phone and computer if it will import them all

  • Oracle DB prerequisites for installing OWB?

    Hi, I am planning to install OWB for a prototype project for a client. But I wanted to make sure that whatever I do now can be repeated at the time of the actual project too. For other things, I see no problem, but installation remains one. I need to

  • Error message while login

    Hi ... When i try to login to system through logon pad.i am getting popup box  "SAP system message S" and i am not able to login to that particular system. can you please provide the solution. V.G.M. Dilip Kumar