Shell script

Discussion in 'Perl Misc' started by Shabam, Sep 27, 2005.

  1. Shabam

    Shabam Guest

    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.
    Shabam, Sep 27, 2005
    #1
    1. Advertising

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


    Shabam <> wrote:

    > 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


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Sep 28, 2005
    #2
    1. Advertising

  3. Shabam

    Shea Martin Guest

    Shabam wrote:
    > 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
    Shea Martin, Nov 10, 2005
    #3
  4. [ follow-ups trimmed to clpm ]

    On Thu, 10 Nov 2005 14:36:26 GMT, Shea Martin <null@void.0> wrote:
    > Shabam wrote:
    > >
    > > 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.


    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

    --
    Michael Zawrotny
    Institute of Molecular Biophysics
    Florida State University | email:
    Tallahassee, FL 32306-4380 | phone: (850) 644-0069
    Michael Zawrotny, Nov 10, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christian Heimes
    Replies:
    0
    Views:
    601
    Christian Heimes
    Feb 27, 2008
  2. Gerardo Herzig
    Replies:
    1
    Views:
    1,078
    Philipp Pagel
    Feb 27, 2008
  3. D'Arcy J.M. Cain
    Replies:
    0
    Views:
    864
    D'Arcy J.M. Cain
    Feb 27, 2008
  4. Samuel A. Falvo II
    Replies:
    0
    Views:
    483
    Samuel A. Falvo II
    Oct 8, 2008
  5. moongeegee

    execute a shell script in a shell script

    moongeegee, Dec 3, 2007, in forum: Perl Misc
    Replies:
    2
    Views:
    250
    Ben Morrow
    Dec 4, 2007
Loading...

Share This Page