Read variables from a text file for use in csh script
Hello,
I have a text file (say, declarevars.txt) that contains multiple lines that are essentially meant to be variable declarations:
I want to be able to read this text file within a csh (sorry) script and have that script treat these lines as if they are part of the script. That is, after reading the text file, if I write
within the script, it would print out
My reason for doing this instead of setting the variables within the script itself is more for neatness and convenience. I would be using a lot of different scripts doing different things but each would be using these same variables and I didn't want the first 50 lines of each script to always be variable declarations.
Based on what I've found from forums, I have tried the following
and
However, none of these seem to work. I am hoping that someone can help me with this question. Thank you very much!
Last edited by Scrutinizer; 06-11-2016 at 06:05 AM..
Reason: Bold tags -> Code tags
I have a file containing multiple values, some of them are pipe separated which are to be read as separate values and some of them are single value all are these need to store in variables.
I need to read this file which is an input to my script
Config.txt
file name, first path, second... (7 Replies)
I have a input file like this.
Sample.txt
30 | TXDatacenter | TXBackupDC
10 | UKDatacenter | UKBackupDC
0 | NLDatacenter | NLBackupDC
......
......
......
I need to get these values in different variables like this.
Load1=30
PriCenter1=TXDatacenter... (5 Replies)
Hi,
I have a text file as follows:
a.txt
------
STEPS=3
STEP_DURATION=100
INTERVAL=60
I want to use these values in a shell script.
How to go about this? (3 Replies)
For eg: I have sample.txt file with 4 rows of record like:
user1|password1
user2|password2
user3|password3
user4|password4
The username and password is sepsrated by '|'
I want to get the 1st row value from the file and assign it to two different variables(username and password)
in my... (1 Reply)
I cannot get the following substitution ($ORACLE_SID) to work:
The variable ORACLE_SID is set to wardin my environment. It has been exported.
I have a text file called test.dat:
/u07/oradata/${ORACLE_SID}/extab/finmart/summit/ps_voucher_line_crnt_ex.dbf... (2 Replies)
Ok, I sort of need to create a command files that will be ftped to another server to run.
I have some input variable that will need to be read, and then transformed into another script file. Here are some examples.
Server 1:
outputCmd.sh
passing in ./outputCmd.sh nh8oaxt Release_4_0... (1 Reply)
I am new to scripting and I needed to know if there would be an easy way to delete extra spaces in a text file. I have a file with three rows with 22 numbers each, but there is extra spaces between the numbers when it gets output by this program AFNI that I am using. What script would help delete... (2 Replies)
Dears,
I developed a shell script to read varibales from text file as the following:
cat /dev/null > /rename-OUT.txt
while read line
do
set -- `echo $line`
snmpset -c dslmibs $1 sysName.0 octetstring $2
after=$(snmpget -c dslmibs $1 sysName.0 | cut -d: -f3)
echo "$1,$2,$after" >>... (1 Reply)
Hello,
I have a cat.dat file, i would like shell to read each 3 lines and set this 3 lines to 3 different variables.
my cat.dat is:
11
12
+380486461001
12
13
+380486461002
13
14
+380486461003
i want shell to make a loop and assign 1st line to student_id, 2nd line to... (4 Replies)
Dears,
This is what i want..
I need to read a comma separated text file whose name is config.txt.
whose content is like ;
bscnara,btserrr
bscsana,btssanacity
.....
i need to read the first string and second string and use it to execute a another shell script.
This is the logic.
... (1 Reply)