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.

link|improve this question

61% accept rate
@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
feedback

1 Answer

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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