Sponsored Content
Top Forums Shell Programming and Scripting Variables of executed script available in executing script Post 302419941 by dips_ag on Monday 10th of May 2010 06:54:07 AM
Old 05-10-2010
Variables of executed script available in executing script

Hi,

I have a script get_DB_var.ksh which do a data base call and get some variables as below:

Code:
 
sqlplus -silent $user/$pass@dbname <<END
select col1,
         col2,
         col3
from table_name where col4=$1;
exit;
END

Now I want to access all these variables i.e. col1,col2,col3... in the script that executes get_DB_var.ksh as below:

Code:
 
cat set_DB_var.ksh
 
ksh get_DB_var.ksh 
echo $col1
echo $col2
echo $col3

is this possible? or do I have to write values of col1,col2,col3... in a file and then read it in set_DB_var.ksh?
Code:
 
get_DB_var.ksh 
---------------
sqlplus -silent $user/$pass@dbname <<END > var_file.txt
select col1,
         col2,
         col3
from table_name where col4=$1;
exit;
END
 
set_DB_var.ksh
---------------
while read var_file
do
echo $col1
echo $col2
echo $col3
done

What I want to know is that do we have some command to see the variables of the executed script?? the similar way we have "export" command to have variables available in the called script!

-dips
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to know who executed a script?

Dear all I would like to capture who executed a script to a script's variable (i.e. testing.sh), so I can save it to a log file. testing.sh #! bin/ksh user=`<< code here >>` // get the info below in RED color <<main logic>> echo "$user execute testing.sh on `date`" >> testing.log ... (2 Replies)
Discussion started by: on9west
2 Replies

2. UNIX for Advanced & Expert Users

Executing a shell script from windows;script present in unix

I need to execute a shell script kept in unix machine from windows. User id, password area available. For eg. There's a shell script wich moves all the logs kept in my home directory to a directory named LOGS. Now i need to get this done through windows; either using a batch file, or java... (4 Replies)
Discussion started by: rajneesh_kapoor
4 Replies

3. AIX

Script not getting executed via cron but executes when executed manually.

Hi Script not getting executed via cron but executes successfully when executed manually. Please assist cbspsap01(appuser) /app/scripts > cat restart.sh #!/bin/ksh cd /app/bin date >>logfile.out echo "Restart has been started....." >>logfile.out date >>logfile.out initfnsw -y restart... (3 Replies)
Discussion started by: samsungsamsung
3 Replies

4. Shell Programming and Scripting

script has been executed successfully or not??

Guys, How can we know whether a script has been executed successfully or not ? We dont have any log directories, and we are not given a chance to modify the script. Could someone help me out with this Thanks (2 Replies)
Discussion started by: bobby1015
2 Replies

5. UNIX for Dummies Questions & Answers

Script dosent exits after executing the script

Hi i wrote a script which dosent exists after executing any help #!/bin/bash netstat -ptlen | grep 10000 if ; then echo "Hive Thrift server is running" exit 0 else echo "Hive Thrift server is down Trying to Bring up the service" | mail -s "ALERT" team@domain.com `nohup hive... (7 Replies)
Discussion started by: vikatakavi
7 Replies

6. Shell Programming and Scripting

Shell script executed from Informatica ETL tool is spawning 2 processes for one script

Hi, I am having a shell script which has a while loop as shown below. while do sleep 60 done I am executing this script from Informatica ETL tool command task from where we can execute UNIX commands/scripts. When i do that, i am seeing 2 processes getting started for one script... (2 Replies)
Discussion started by: chekusi
2 Replies

7. Shell Programming and Scripting

Shell script not getting executed

Hi As per my requirement when I run . ./file.sh am getting the following error -bash:ELF: command not found when i execute as ./file.sh it is getting executed.How to resolve this. Thanks in advance. (3 Replies)
Discussion started by: pracheth
3 Replies

8. Shell Programming and Scripting

INIT Script Getting Executed Twice?

Hello All, I copied and pasted the "/etc/init.d/skeleton" file to a new one so I could create my own init script for a program. Basically the ONLY edit I made to the skeleton "template" so far was to search and replace "FOO" with "snort". *NOTE: I know there are a bunch of snort init scripts... (6 Replies)
Discussion started by: mrm5102
6 Replies

9. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

10. Shell Programming and Scripting

Script is not getting executed

Hi All, I have written a programme where i need to work in one session but when that session get executed it doesnt execute other programme till I write exit. Below is the script #!/bin/bash echo 'Going to start' exectrusteduser.com sh.com cd /UAT_Logs/CDCI_LOGS/SEEDADM pwd echo... (6 Replies)
Discussion started by: ripudaman.singh
6 Replies
PG_CONNECT(3)															     PG_CONNECT(3)

pg_connect - Open a PostgreSQL connection

SYNOPSIS
resource pg_connect (string $connection_string, [int $connect_type]) DESCRIPTION
pg_connect(3) opens a connection to a PostgreSQL database specified by the $connection_string. If a second call is made to pg_connect(3) with the same $connection_string as an existing connection, the existing connection will be returned unless you pass PGSQL_CONNECT_FORCE_NEW as $connect_type. The old syntax with multiple parameters $conn = pg_connect("host", "port", "options", "tty", "dbname") has been deprecated. PARAMETERS
o $connection_string - The $connection_string can be empty to use all default parameters, or it can contain one or more parameter settings separated by whitespace. Each parameter setting is in the form keyword = value. Spaces around the equal sign are optional. To write an empty value or a value containing spaces, surround it with single quotes, e.g., keyword = 'a value'. Single quotes and backslashes within the value must be escaped with a backslash, i.e., ' and \. The currently recognized parameter keywords are: $host, $hostaddr, $port, $dbname (defaults to value of $user), $user, $password, $connect_timeout, $options, $tty (ignored), $sslmode, $requiressl (deprecated in favor of $sslmode), and $service. Which of these arguments exist depends on your PostgreSQL version. The $options parameter can be used to set command line parameters to be invoked by the server. o $connect_type - If PGSQL_CONNECT_FORCE_NEW is passed, then a new connection is created, even if the $connection_string is identical to an exist- ing connection. RETURN VALUES
PostgreSQL connection resource on success, FALSE on failure. EXAMPLES
Example #1 Using pg_connect(3) <?php $dbconn = pg_connect("dbname=mary"); //connect to a database named "mary" $dbconn2 = pg_connect("host=localhost port=5432 dbname=mary"); // connect to a database named "mary" on "localhost" at port "5432" $dbconn3 = pg_connect("host=sheep port=5432 dbname=mary user=lamb password=foo"); //connect to a database named "mary" on the host "sheep" with a username and password $conn_string = "host=sheep port=5432 dbname=test user=lamb password=bar"; $dbconn4 = pg_connect($conn_string); //connect to a database named "test" on the host "sheep" with a username and password $dbconn5 = pg_connect("host=localhost options='--client_encoding=UTF8'"); //connect to a database on "localhost" and set the command line parameter which tells the encoding is in UTF-8 ?> SEE ALSO
pg_pconnect(3), pg_close(3), pg_host(3), pg_port(3), pg_tty(3), pg_options(3), pg_dbname(3). PHP Documentation Group PG_CONNECT(3)
All times are GMT -4. The time now is 11:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy