Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Trying to figure out how the environment variables are being set Post 302998519 by Don Cragun on Friday 2nd of June 2017 04:28:33 PM
Old 06-02-2017
You use the dot command:
Code:
. filename

to have the current shell execute the commands in filename in your current shell execution environment. This works as long as filename is readable by you. Since the commands in filename were executed in the current shell execution environment, any variables set while it was running will be available for you to use in subsequent commands.

You use the command:
Code:
filename

(without the .) to run the commands in filename in a separate shell execution environment . When the commands in filename are done, that separate shell execution environment is deleted and anything that commands in filename did that did not change other files or were not written somewhere disappear. This doesn't work unless you have permission to execute filename and filename is on your search path for commands (as specified by the PATH environment variable).

But, it is also possible for a shell script to set up an environment and invoke an interactive database session. That script will not end until the interactive session is terminated by logging out of the database session.

All of the above are possible whether or not filename's first character is a <period>. The best way to figure out what a script might do is usually to read the file and look at the manual pages for your system to figure out what the commands in that file are doing.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to set up linux environment variables?

Hi I'm using Linux, in the directory /root/my there is a.out. but when I try to run it , the shell indicate "bash:a.out: command not found" but I AM working in this directory. if I use "./a.out" , it works perfectly. can any body tell me how to do a permanent set up so that I can use... (5 Replies)
Discussion started by: dell9
5 Replies

2. UNIX for Advanced & Expert Users

by using c++ how to set environment variables in unix

hi, I am writing c++ code in unix operating system.In that i need to set the environment variable in unix. suppose previously i have environment variable like path="something" now i need to change the path value to some othervalue . so that some other program will access that path value... (1 Reply)
Discussion started by: sada@123
1 Replies

3. Shell Programming and Scripting

Help to set the oracle environment????

Hi, I am trying to set the environment for my oracle database. I have 5 database in an unix box. My idea is to create 5 files for each database with the following script on it. After logging into the unix box ...just by typing the database name....the enviornment for the database... (2 Replies)
Discussion started by: castlerock
2 Replies

4. Shell Programming and Scripting

How does the environment stay set

I am running this pre-script with a post scripts that needs to share the same variables. How do I keep the environment variable settings for the next script to access from the RMAN Script? Prescript #1 #RMAN Script #!/bin/ksh ORACLE_SID=INVPRD;export ORACLE_SID... (1 Reply)
Discussion started by: gzs553
1 Replies

5. Solaris

set environment variable?

I am working with solaris 9 sunBlade150 Box. I Installed a program, need to set the environment variable so that when the executable is entered,it finds the path to the executable. The documentation for the software says: Set the appropriate environment variable: Connect to server failed;... (8 Replies)
Discussion started by: smartgupta
8 Replies

6. Shell Programming and Scripting

Set environment

Hi, I can run shell script from the command line using $ . set If the run the script inside perl script using $var = system("set"); print $var; This prints 0. This command sets up the environment from command line. But when used inside the shell script or perl script it... (2 Replies)
Discussion started by: sandy1028
2 Replies

7. SCO

Help finding where certain environment variables are set

i have two machines that should be identical but on one system there are some oracle environment (ORACLE_SID, ORACLE_HOME, etc...) variables that are not being set for the users. I am trying to find where those environment variables are being set on the system which is working properly. All... (5 Replies)
Discussion started by: kuliksco
5 Replies

8. Shell Programming and Scripting

perl. How to set persistent environment variables

I have test.pl scrit with these few lines. #!/usr/bin/perl $ENV{'ORACLE_SID'} = "D3771"; $ENV{'ORACLE_HOME'} = "/oracle/product/10.2.0/db_1"; When I try . test.pl it throws an error. When I try test.pl, it doesn't reaing the variables I set in the script. -> . test.pl ksh:... (10 Replies)
Discussion started by: MKNENI
10 Replies

9. Shell Programming and Scripting

Need to SET Environment variables

Hi Could you please tell me how to set environment variables in Unix ksh. And how can acess those varibles in shell scripts ( Please give the code with an example) For my scenario. We have written number of shell scripts with hard coded username and password. But if we want to... (1 Reply)
Discussion started by: shyamu544
1 Replies

10. Shell Programming and Scripting

Help with change significant figure to normal figure command

Hi, Below is my input file: Long list of significant figure 1.757E-4 7.51E-3 5.634E-5 . . . Desired output file: 0.0001757 0.00751 0.00005634 . . . (10 Replies)
Discussion started by: perl_beginner
10 Replies
command(1)						      General Commands Manual							command(1)

NAME
command - Treats command arguments as simple commands SYNOPSIS
command [-p] command_name [argument...] command [-v | -V] command_name The command command causes the shell to treat the arguments to command as simple commands, and suppresses the default shell function lookup. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: command: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
Performs the command search using a default value for PATH that is guaranteed to find all of the standard utilities. Writes a string to standard output that indicates the path name or command to be used by the shell in the current shell execution environment to invoke com- mand_name. Writes a string to standard output that indicates how the name given in the command_name operand will be interpreted by the shell in the current shell execution environment. DESCRIPTION
The command command allows you to run the following commands: User-defined commands whose names correspond to shell built-in commands. System commands whose names correspond to shell built-in commands. The command_name argument specifies the name of a utility. The one or more optional arguments to command_name specify strings treated as arguments to the specified utility. It also provides information concerning how a command name will be interpreted by the shell. NOTES
[Tru64 UNIX] If command_name is not the name of a function, the effect of command is the same as would be obtained by specifying com- mand_name without command. RESTRICTIONS
Since the -v and -V options to command produce output in relation to the current shell execution environment, if command is called in a subshell or separate utility execution environment, it may not produce correct results. The following are examples of this type of opera- tion: (PATH=foo command -v) nohup command -v EXIT STATUS
When the -v or -V options are specified, command returns one of the following values. Successful completion. The command_name could not be found, or an error occurred. If the -v or -V options are not specified, command returns one of the following values on error. The utility specified by command_name was found but could not be invoked. An error occurred in the command command, or the utility specified by the command_name argument could not be invoked. If no error occurs, the exit status of command is that of the command specified by the arguments to command. EXAMPLES
To ensure execution of the simple command pwd instead of the pwd shell built-in command, enter the following: command -p pwd The preceding command displays the full path name of the current directory, and does not perpetuate a view of the current directory loca- tion created by links as the shell built-in command might do. ENVIRONMENT VARIABLES
The following environment variables affect the execution of command: Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization variables contains an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale that should be used to affect the format and contents of diagnostic messages written to standard error. Determines the location of message cat- alogues for the processing of LC_MESSAGES. Determines the search path used during the command search unless the -p option is specified. SEE ALSO
Commands: env(1), hash(1), type(1) Standards: standards(5) command(1)
All times are GMT -4. The time now is 12:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy