This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Bash call variables from one script to other

Dear All,

I am trying to call variables from one shell script to other. I used "source" and "export" but none are doing the job. A mention, that it is CGI bash script. And in the bash script there is also "<href>" HTML links to other CGI scripts. For example - I am doing like this;

script1: test1.sh

#!/bin/sh
echo "Content-type: text/html"
echo ""
....
export XX="1"
export YY="2"
 "echo "<p><a href = "/path/to/second/CGI/script/test4.sh" >to choose click</a></p>"

script 2: test4.sh

#!/bin/sh
echo "Content-type: text/html"
echo ""
echo "<html>"
echo "<body>"
echo "<form action="/path/to/third/CGI/script/test5-1.sh" method="GET">"
echo "</form>"
echo "</body>"
echo "</html>"
echo "XX =$XX"

script 3: test5-1.sh

#!/bin/sh
#source <(grep '^export .*=' test1.sh)
echo "Content-type: text/html"
echo ""
echo "XX = $XX"

but it gives me nothing in "test5-1.sh"

So, I called "test4.sh" from "test1.sh" and exported all variables of "test1.sh" as shown above. All the variables are exported well to "test4.sh" but the variables are not getting exported to "test5-1.sh" from "test1.sh". I want to use the variables of "test1.sh" in "test5-1.sh" also. Likewise, I have other bash scripts in the same directory, in which I would like to export the variables and their values from "test1.sh". Can you please let me know how can I do it? I tried "source" like above in "test5-1.sh" but it does not work. Please let me know if you need more information on this.

Thank you so much! DK

bash

Hello deepak.k.choubey!

We believe that this post does not fit the main topic of this site.

Not a bioinformatics question.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

Awww that was a close call. Looks like you beat me by a few seconds.

Hello deepak.k.choubey!

We believe that this post does not fit the main topic of this site.

Not related to bioinformatics, try stackoverflow

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

Seems like there is a kind of moderator competition going on :P

0 answers

No answers yet.

Log in to answer this question.