Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The title may not be much clear. I have written some scripts for housekeeping tasks on the Ubuntu servers we maintain. When ever there is a new deployment for a client, I have to change user ids, passwords and names of the servers etc. to make scripts usable in new setup.

Is there any way which help me to define all these things as variables and use then in all scripts. Like define them in a shell file and then access that file in all other scripts...?

EDIT:-

an example backup script:

BACKUPSERVER=192.168.1.123
BACKUPPATH=/home/user1/nightlybackups
BACKUPUSER=user1
PASSWORD=user1secret
MYSQLUSER=dbuser1
MYSQLPWD=dbuser1secret

#..... actual script that uses values above and perform backup etc.

There are quite a few scripts like this that use variables. I want a common place to define them and then access in any script.

share|improve this question
    
@slhck I have edited question to add an example. –  TheVillageIdiot Oct 27 '11 at 15:41
    
You could just dynamically generate the scripts. . . –  surfasb Oct 27 '11 at 17:20
    
@surfasb would you please elaborate on this? –  TheVillageIdiot Oct 27 '11 at 17:41

1 Answer 1

Put all the variables in a file, say "server.specific.variables". Then each script can include that file with
. server.specific.variables

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.