1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

passing paramter from one script to another script in perl

Discussion in 'Perl' started by john83reuben, Feb 28, 2008.

  1. john83reuben

    john83reuben New Member

    Joined:
    Feb 19, 2008
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    Hi guys. I have a question, just wondering bout it. JUst say I have a script called firstscript.pl

    #!/usr/bin/perl

    print "enter name\n";
    $name = <STDIN>;

    How to pass $name paramter to another script.

    For example, my second script is called secondscript.pl

    #!/usr/bin/perl

    print "the name entered is $name\n";

    Pls help guys..
    Thank you.
     
  2. john83reuben

    john83reuben New Member

    Joined:
    Feb 19, 2008
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    Guys, I have solved the above problem.

    firstscript.pl


    #!/usr/bin/perl

    use CGI;

    print "enter name\n";
    $name = <STDIN>;

    #system("./pass2.pl $name" == 0);
    #use pass2.pl (name);

    our($username) = ($name);do "pass2.pl";


    secondscript.pl

    #!/usr/bin/perl

    print "the name enter was $username\n";
     
  3. john83reuben

    john83reuben New Member

    Joined:
    Feb 19, 2008
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    Now I have a problem, I user the same technique, but this time is not happening. Can u guys look through my code, and see whats the problem

    firstscript.cgi

    #!/usr/bin/perl

    use strict;
    use CGI;

    my $q = new CGI;
    my $name = $q->param( "name" );
    my $password = $q->param( "password" );
    my $pass = crypt($paswd,"password");
    our($username,$paswd) = ($name,$pass);do "secondscript.cgi";
    system("sudo su assistant");

    secondscript.cgi

    #!/usr/bin/perl

    system("sudo /usr/sbin/useradd -m -p $paswd $username");


    Since this is regarding creating username and etc, I have done some apache configuration and etc/sudoers configuration.

    pls help
     

Share This Page