getting vars from external files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting getting vars from external files
# 1  
Old 09-04-2012
getting vars from external files

Hi I have an issue, I want to get variables from an external file. Variable file var1=test var2-test2 I want to get these vars from another shell script. Does any one know how?
# 2  
Old 09-04-2012
Make the file like this

Code:
var1=test
var2=test2

then you just do . configfile in your script and it sets the variables.
# 3  
Old 09-04-2012
Still can't work it out

Could you explain in more detail. Cheers
# 4  
Old 09-04-2012
Quote:
Originally Posted by digitalviking
Could you explain in more detail. Cheers
What is it that's not clear?
# 5  
Old 09-04-2012
Whats confusing

config called config.txt file contains var1=test1 var2=test2 shell script contains . contfig.txt it this right?
# 6  
Old 09-04-2012
Quote:
Originally Posted by digitalviking
config called config.txt file contains var1=test1 var2=test2 shell script contains . contfig.txt it this right?
that's correct - just as Corona688 has explained. The name of a file doesn't matter as long as you the same name when 'sourcing' it with . myFileWithVariables
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

I want to copy all files of a said type on my external hard drive

My code is this, what I'm trying to accomplish is to make a list of all pdf documents in my computer and then copy all of those documents to my external hard drive in a directory mkdir /Volumes/Hardrive-1/allpdf echo "File Locations" > /Volumes/Hardrive-1/allpdf/FileLocations.txt mdfind pdf... (2 Replies)
Discussion started by: darpness
2 Replies

2. Shell Programming and Scripting

Apache Hosting-Shell Script - external files include

Hi there Well, it's my first time on this board, so short to myself: I'm matibaski, working as a webdeveloper and also as a system administrator on ubuntu server machines. The problem: I created a small apache-hostingscript by myself and it works fine. But after some addings and new... (1 Reply)
Discussion started by: matibaski
1 Replies

3. Shell Programming and Scripting

Editing external files

I am running Matlab in a unix enviroment and in my Matlab program I am calling an outside program (mav) to run with a unix command in Matlab: unix('mav -u 5 -c 1 -s') My goal is to edit the input files (three different files) for that external program and then run that external program... (0 Replies)
Discussion started by: heatona
0 Replies

4. UNIX for Dummies Questions & Answers

Copying files unto a usb pendrive/external disk from Solaris 9

Hi all, Can anybody help me with how I can connect a usb pendrive or external disk to a Sun Server which runs on Solaris 9? I am able to connect the usb drive to a windows server easily and copy files but am wondering if it is possible to do that with Solaris. Any help will be appreciated. thanks. (3 Replies)
Discussion started by: rahmantanko
3 Replies

5. Programming

JAVA - External JAR files in UNIX

Hi, I have to run my JAVA programs in UNIX server. The java program uses some external jar files for compiling. I have set the classpath to the folder where all the jar files are present using EXPORT classpath command. But when i compile, it shows errors.. saying that the classes relating... (8 Replies)
Discussion started by: satish2712
8 Replies

6. Shell Programming and Scripting

Substituting variables from external files

Hi All, I have the following problem: 1. I have a file containing a line: a,b,d,${d},e,f 2. From within a script I grep the file for '^a,' to get the line 3. I obtain the fourth field as follows: Field4="$( print -r $fileEntry | cut -d, -f4 )" 4. The script exports variables at the... (1 Reply)
Discussion started by: oneillc9
1 Replies

7. UNIX for Dummies Questions & Answers

Accessing files on external USB drive using UNIX?

Hi Folks, I'm a serious UNIX newbie... I'm using a bash shell on Mac OS X. Basically I took up unix in order to use a specific image processing software package... I've learned enough to write a script to batch process all of my images, but I have so many that I would like to use an... (1 Reply)
Discussion started by: Slanter
1 Replies

8. Shell Programming and Scripting

how to include external files in tcsh

Hello Simple question about tcsh , i like to make external file that some tcsh script will read from him var=="some value" how can i make the include in tcsh files? Thanks (0 Replies)
Discussion started by: umen
0 Replies

9. Filesystems, Disks and Memory

automatic copying files from external hard drives

I need to make it possible to automatically copy files from an external usb hard drive to a directory when i plug it in....if you can point me in the right direction, i would be very grateful....thanks a lot. :confused: (0 Replies)
Discussion started by: backman4sakn
0 Replies

10. OS X (Apple)

Help with copying files to external drive in single user mode

I'm a newbie to Unix and hoping that it will be my saviour when all else has failed. My "keys out of order" on my g4 laptop and neither Disk Util nor Disk Warrior can fix it. I'm experimenting in the unix command line (I figure I can't mess this laptop up anymore , and have figured out how... (3 Replies)
Discussion started by: mishostawn
3 Replies
Login or Register to Ask a Question