Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to define multiple environment variables in a shell script? Post 303045861 by sravani25 on Thursday 16th of April 2020 06:26:49 AM
Old 04-16-2020
How to define multiple environment variables in a shell script?

Hi All,
I am running a shell script on centos 7 to get some variable values and want to declare them as environment variables so that i will use them in another shell script.

I am using below script i am able to define one environment variable but it's not allowing me to do for another variable.

Can someone please help me on this issue.

Code:
 path=$(find $config_path -name abc.txt 2>/dev/null )

domain_path=$(cat $path |grep "domain location" )
 
boot=$(find $config_path -name boot.properties 2>/dev/null |head -1 )

 user_name=$(cat $boot |grep username)
echo 'export NAME=$user_name' >> ~/.profile

  passwd=$(cat $boot |grep password)
  echo $passwd
  echo 'export TEST=$passwd' >> ~/.bash_profile

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script help: sorting, incrementing environment variables and stuff

First: me == noob. Whats a good resource for shell script info cause I'm having trouble finding good info. I'm writing a shell script to automate the setup of a flash 'page flip'. My current code is below. the page flip takes an xml file of format <content> <pages... (1 Reply)
Discussion started by: secoif
1 Replies

2. Shell Programming and Scripting

problem accessing Multiple Variables from C Program to a Shell script

program name--test #!/bin/bash output1=`/home/user/a.c` output2=`/home/user/a.c` k=`$output1 + 1` m=`$output2 + 1` echo $k echo $m --------------------------------------------------------------------------- prgram name--a.c #include<stdio.h> int main() (1 Reply)
Discussion started by: sameworld1980
1 Replies

3. Emergency UNIX and Linux Support

Problem setting environment variables from script

Hi all! I know that environment variables can be set on the .bashrc file, but I need to set them from a sh script. I saw a lot of websites that teach this but it doesn't work for me. #!/bin/sh DEKTOP=$DESKTOP=:/home/rrodrigues/Desktop export DESKTOP if I do echo $DESKTOP returns me... (10 Replies)
Discussion started by: ruben.rodrigues
10 Replies

4. UNIX for Dummies Questions & Answers

Define variables with UNIX script

oopps! I Meant "Define Variables within a UNIX Script" What would be the best way to define a variable in a unix shell script so anyone who views this script doesn't know what value is assigned to that variable. some other location... a="/usr/lib/fileA" Unix script... sed... (5 Replies)
Discussion started by: macastor
5 Replies

5. Shell Programming and Scripting

environment variables in a sed script file

Hello Everyone I need to create a script file which must append some lines to a target text file, I'm using sed for windows, the script file look like this: { a\ STRINGTABLE DISCARDABLE\ BEGIN\ 5, 150 {a\ #define RC_SHELL, "%ID_SHELL%"\ #define RC_NAME, "%ID_NAME%"\ END } ... (1 Reply)
Discussion started by: edgarvm
1 Replies

6. Shell Programming and Scripting

Using Datastage environment variables in Unix script

Hi All, I am using ETL tool Datastage and is installed on Linux environment. Few environment variables are set in datastage. Now my requirement is to use those environment variables in a unix script. Is there any option I can do it? Sugeestions from people working on datastage and linux... (1 Reply)
Discussion started by: bghosh
1 Replies

7. Shell Programming and Scripting

Using a script to define variables and run multiple other scripts in succession.

I'm pretty new to scripting in Korn shell so please forgive me... What I'm trying to do is to create a script that calls multiple other ksh scripts and defines variables for text files. I need it to define my user defined variables (file paths, date & time stamps, etc that are currently in... (1 Reply)
Discussion started by: bluejwxn8
1 Replies

8. Shell Programming and Scripting

Sourcing .cshrc (C shell) environment variables to bash

I have tried with the following: csh -c 'source ~/.cshrc; exec bash' # works perfectly (cat ~/.cshrc; echo exec bash) | csh # not working And, using sed, I successfully retrieved the environment variables from ~/.cshrc sed -rn 's/setenv\s+(\S+)\s+(.*)$/export \1=\2/p' ~/.cshrc but now... (6 Replies)
Discussion started by: royalibrahim
6 Replies

9. Linux

How to store count of multiple queries in variables in a shell script?

how to store the count of queries in variables inside a filein shell script my output : filename ------- variable1=result from 1st query variable2=result from 2nd query . . . . (3 Replies)
Discussion started by: sanvel
3 Replies

10. Shell Programming and Scripting

How to define two digits variable in shell script?

Dear Shell script Experts, I am working on shell script which is defined here, qsub_seq.csh . The purpose of this script is to read few input files (with defined starting index and last index) and make processing faster over server. For some task, I had 1064 of input files, so I wrote another... (8 Replies)
Discussion started by: emily
8 Replies
SULOGIN(8)						Linux System Administrator's Manual						SULOGIN(8)

NAME
sulogin -- Single-user login SYNOPSIS
sulogin [ -e ] [ -p ] [ -t timeout ] [ tty-device ] DESCRIPTION
sulogin can be invoked by init(8) when the system goes into single user mode (this is done through an entry in inittab(5)). Init also tries to execute sulogin when it is passed the -b flag from the bootmonitor (eg, LILO). The user is prompted Give root password for system maintenance (or type Control-D for normal startup): sulogin will connected to the current terminal, or to the optional device that can be specified on the command line (typically /dev/con- sole). If the -p flag was set, the single-user shell will be invoked with a dash as the first character in argv[0]. That will cause most shells to behave as a login shell. The default is not to do this, so that the shell will not read /etc/profile or $HOME/.profile at startup. After the user exits the single-user shell, or presses control-d at the prompt, the system will (continue to) boot to the default runlevel. ENVIRONMENT VARIABLES
sulogin looks for the environment variable SUSHELL or sushell to determine what shell to start. If the environment variable is not set, it will try to execute root's shell from /etc/passwd. If that fails it will fall back to /bin/sh. This is very valuable together with the -b flag to init. To boot the system into single user mode, with the root file system mounted read/write, using a special "failsafe" shell that is statically linked (this example is valid for the LILO bootprompt) boot: linux -b rw sushell=/sbin/sash FALLBACK METHODS
sulogin checks the root password using the standard methods first. If the -e option was specified, sulogin examines the next files to find the root password. If they are damaged, or non-existant, it will use fallback methods that even go so far as to provide you with a shell prompt without asking for the root password if they are irrepairably damaged. /etc/passwd, /etc/shadow (if present) AUTHOR
Miquel van Smoorenburg <miquels@cistron.nl> SEE ALSO
init(8), inittab(5). 11 Sep 2000 SULOGIN(8)
All times are GMT -4. The time now is 02:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy