Question: (Closed) Bash call variables from one script to other
0
gravatar for DanielC
3.3 years ago by
DanielC130
Canada
DanielC130 wrote:

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 • 904 views
ADD COMMENTlink modified 3.3 years ago by genomax92k • written 3.3 years ago by DanielC130

Better place to ask this question would be https://stackoverflow.com/

ADD REPLYlink written 3.3 years ago by venu6.7k

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!

ADD REPLYlink written 3.3 years ago by Michael Dondrup48k

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

ADD REPLYlink written 3.3 years ago by WouterDeCoster44k

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!

ADD REPLYlink written 3.3 years ago by WouterDeCoster44k

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

ADD REPLYlink written 3.3 years ago by venu6.7k
Please log in to add an answer.
The thread is closed. No new answers may be added.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1297 users visited in the last hour