Problem in passing values to perl script using another perl script

Discussion in 'Perl Misc' started by vikrant, Aug 10, 2005.

  1. vikrant

    vikrant Guest


    i have two perl scripts and #script store in /home/bob directory
    print"Enter the user name";
    $name = <STDIN>;
    print "$name";
    ---------------------------------- # script store in /home/bob directory
    $user_name = "BOB";

    system("perl /home/bob/");

    # output after running

    Enter the user name

    It asked me to enter user name. Now,i have to enter the value using my
    keyboard but i do not want to do so.

    i want that the value of "$user_name" pass to this automatically.

    But,i am not able to do so.

    Due to some reason i do not want to make use of command line arguments.

    Actullay,I am new to perl so please let me know if am missing something.

    With Regards
    vikrant, Aug 10, 2005
    1. Advertisements

  2. Then make use of the @ARGV variable and don't fork a new process, i.e.
    use do() or require() instead of system().
    Gunnar Hjalmarsson, Aug 10, 2005
    1. Advertisements

  3. vikrant

    Joe Smith Guest

    $user_name = 'BOB';
    open my $pipe,'|-','perl /home/bob/'
    or die "Could not open pipe: $!";
    print $pipe $user_name,"\n";
    close $pipe or warn "Problems on pipe close: $!";

    This is assuming you really have a need for executing
    as a separate process, as opposed to using
    use '/home/bob/';
    require '/home/bob/';

    Joe Smith, Aug 10, 2005
  4. vikrant

    vikrant Guest

    Thanks for the information.

    vikrant, Aug 10, 2005
  5. vikrant


    $user_name = "BOB";
    warn "This is probably a stupid way to solve whatever your root problem
    is"; system("echo $user_name | perl /home/bob/")

    If you are not able to do things in the most appropriate manner due to some
    bizarre reason, and you fail to explain what that bizarre reason is, how
    are we supposed to help circumvent that bizarre limitation? Any solution
    we propose from out of the darkness is also likely to run afoul of the same
    bizarre, unexplained reason that prevents you from doing it right in the
    first place.

    (But in this case, "doing it right" is at least as likely to be modules,
    rather than command line arguments in a system call.)

    , Aug 10, 2005
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.