User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 456,428 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,572 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 995 | Replies: 4
Reply
Join Date: May 2005
Posts: 229
Reputation: nathanpacker is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

little shell scripting help here...

  #1  
Jul 18th, 2007
I originally posted this in the wrong forum, so I hope I don't get ripped apart for a double post. As part of my new job, I'm learning a little shell scripting, working on an HP-UX system.

I'm trying to automate a user account creation process, and I need to access the template file that SAM uses so I can set certain attributes of the user's account, according to the template file. (I know, why not just use SAM? That's the same question I asked my boss, ask him. I don't know.)

Here is a sample of the template file, called /var/sam/ug/templates/ts:


handle 1 {
list UG_TS_UT 1 {
UG_TS_UT {
UG_TS_UT_TITLE = "MyTemplate";
UG_TS_UT_DESC = "User of MyTemplate";
UG_TS_UT_HDPATH = "/home";
UG_TS_UT_SUP = "/bin/tcsh";
UG_TS_UT_PGRP = "users2";
UG_TS_UT_ALTSTR = NULL;
UG_TS_UT_BOOTSU = "NO";
UG_TS_UT_PWDFSGP = "DFT";
UG_TS_UT_PWDFSGC = "DFT";
UG_TS_UT_PWDFSGL = "DFT";
UG_TS_UT_PWDFUSP = "DFT";
UG_TS_UT_PWDFERR = "DFT";
UG_TS_UT_PWDFNUL = "DFT";
UG_TS_UT_PWDFLEN = -1;
UG_TS_UT_PGID = 108;
UG_TS_UT_UIDVAL1 = NULL;
UG_TS_UT_UIDVAL2 = NULL;
UG_TS_UT_LOGENV = NULL;
UG_TS_UT_UIDMETH = 1;
UG_TS_UT_INCCOM = 1;
UG_TS_UT_ACCACT = 1;
UG_TS_UT_ALTTYPE = 1;
UG_TS_UT_ACCLFTM = -1;
UG_TS_UT_MAXPOI = -1;
UG_TS_UT_UNSUCLT = -1;
UG_TS_UT_PWDAGING = -1;
UG_TS_UT_PWDTBC = -1;
UG_TS_UT_PWDEXPT = -1;
UG_TS_UT_PWDWARN = -1;
UG_TS_UT_PWDLFTM = -1;
UG_TS_UT_PWDOPT = 2;
UG_TS_UT_CRHD = 1;
UG_TS_UT_PSD = 1;
};
};
};

Now, if any of you use HP-UX, you'll know that SAM uses the parameters set in this file to create user accounts according to this template, which is called "MyTemplate".

But how can I use these parameters? They don't look like variables, because you can't have spaces before or after the equal sign with variables. So what is this type of script called, and how can I call it in my script to use those values?

sorry this is long, I hope I made sense.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2005
Posts: 229
Reputation: nathanpacker is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Re: little shell scripting help here...

  #2  
Jul 23rd, 2007
Alright, I finally found out that the script is simply a perl script. It's just a bunch of sub-routines naming variables. I was thinking it was a shell script, that's why I was so confused. So now how can I call this file from my shell script, specify the correct sub-routine, then grab the variables from this file to use in my script?
Last edited by nathanpacker : Jul 23rd, 2007 at 1:05 pm.
Reply With Quote  
Join Date: May 2005
Posts: 229
Reputation: nathanpacker is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Re: little shell scripting help here...

  #3  
Jul 25th, 2007
I was just told by someone else that this is not perl. Now I don't know what it is. Please help! All I need to do is know how to grab these variables and use them in my shell script!
Last edited by nathanpacker : Jul 25th, 2007 at 12:25 pm.
Reply With Quote  
Join Date: Feb 2006
Posts: 1,509
Reputation: masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light 
Rep Power: 10
Solved Threads: 136
masijade's Avatar
masijade masijade is offline Offline
Posting Virtuoso

Re: little shell scripting help here...

  #4  
Jul 26th, 2007
Try
sed -e '/[\{\}]/d' -e 's/ = /=/' -e 's/;$//' filename > tmpFile
. tmpFile
rm -f tmpFile

That will turn all those lines with = signs into variables and source them, cleaning up afterwords.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Join Date: May 2005
Posts: 229
Reputation: nathanpacker is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Re: little shell scripting help here...

  #5  
Jul 26th, 2007
thanks! i'll give that a try.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 1:17 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC