Shell script

S

Shabam

Up to now I've been doing this manually via the command shell. However I'm
sure I can automate this using a script with better results. Can someone
show me how I can do this?

cp -pr /site/template/user /site/j/jason
cp -p /site/data/j/jason.dat /site/data/j/jason.dat; pico -w
/site/data/j/jason.dat

In pico I'm basically changing the first 3 lines, replacing the first line
with user "jason"s email, second with his name, and third with his zip code.

I'm trying to come up with a script that will take the username, email,
name, and zip code as arguments. Once done it will perform the above steps
and be done. Can someone perhaps help me with this? I've dabbled in some
Perl, but mostly by editting what's already been made. Thanks.
 
T

Tad McClellan

[ Newsgroups trimmed.
I don't participate in the alt.* hierarchy and comp.lang.perl
was removed many years ago.
]


Shabam said:
I'm trying to come up with a script that will take the username, email,
name, and zip code as arguments.


The command line arguments are available in the @ARGV array.


perldoc perlvar
 
S

Shea Martin

Shabam said:
Up to now I've been doing this manually via the command shell. However I'm
sure I can automate this using a script with better results. Can someone
show me how I can do this?

cp -pr /site/template/user /site/j/jason
cp -p /site/data/j/jason.dat /site/data/j/jason.dat; pico -w
/site/data/j/jason.dat

In pico I'm basically changing the first 3 lines, replacing the first line
with user "jason"s email, second with his name, and third with his zip code.

I'm trying to come up with a script that will take the username, email,
name, and zip code as arguments. Once done it will perform the above steps
and be done. Can someone perhaps help me with this? I've dabbled in some
Perl, but mostly by editting what's already been made. Thanks.

You could learn a minimal amount of perl/ruby/bash/python, then write a
short script to do all this for you. Actually, you could do it will
just the sed command if you are on unix. Thats what I would do.

~S
 
M

Michael Zawrotny

[ follow-ups trimmed to clpm ]

You could learn a minimal amount of perl/ruby/bash/python, then write a
short script to do all this for you. Actually, you could do it will
just the sed command if you are on unix. Thats what I would do.

I would use the Template Toolkit for this. You can setup the template
file and use the tpage program to generate the final version. There
are online tutorials (e.g.
www.devshed.com/c/a/Perl/Getting-Started-with-the-Perl-Template-Toolkit/),
and the sample chapter of "Perl Template Toolkit" that O'Reilly has
graciously posted on the web
(http://www.oreilly.com/catalog/perltt/chapter/ch02.pdf) is probably
enough to get you through the job at hand.

One benefit to you is that you shouldn't need to write any code to use
TT.


Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top