Professional Web Applications Themes

perl interactive system commands - PERL Beginners

rhlinux wrote: > elslam 3alikom, > i wanna run an interactive system command through my program > for example i wanna add a user with its password that is given in the program not by the user, do any one here have any idea how can i do so in perl > i tried > > quote: > ------------------------------------------------------------------------------ > system(passwd username ) > ------------------------------------------------------------------------------ > > but this takes the password from the user, i have also tried a lot of attributes to passwd command but nothing worked I've tried just about every method you can think of to ...

  1. #1

    Default Re: perl interactive system commands

    rhlinux wrote:
    > elslam 3alikom,
    > i wanna run an interactive system command through my program
    > for example i wanna add a user with its password that is given in the program not by the user, do any one here have any idea how can i do so in perl
    > i tried
    >
    > quote:
    > ------------------------------------------------------------------------------
    > system(passwd username )
    > ------------------------------------------------------------------------------
    >
    > but this takes the password from the user, i have also tried a lot of attributes to passwd command but nothing worked
    I've tried just about every method you can think of to get this to work correctly.
    Unfortunately, passwd is coded to only accept from a tty. The only thing I could think of
    to get it to work is to create a pseudo tty (pty) and use that to send input to the passwd
    program. I have no idea how to do this, though. There may also be an easier way.

    --
    Andrew Gaffney

    Andrew Gaffney Guest

  2. #2

    Default Re: perl interactive system commands


    On Monday, Dec 4, 1995, at 15:32 US/Pacific, rhlinux wrote:
    [..]
    >
    > quote:
    > -----------------------------------------------------------------------
    > -------
    > system(passwd username )
    > -----------------------------------------------------------------------
    > -------
    >
    > but this takes the password from the user, i have also tried a lot
    > of attributes to passwd command but nothing worked
    [..]

    the obvious first part of the problem is
    are you running the command as 'root'?
    Since only root can do the change of
    the passwd file(s).

    I have not run into Andrew Gaffney's problem,
    since if this is an application to be run at
    the command line, then one is STILL attached
    to the tty/pty. If this is not going to be
    an interactive command, then we have way
    deeper issues to deal with.

    Depending on which system you are on,
    you may want to look at useradd
    cf man useradd
    for creating a user.

    But back to your core problem, namely that
    the passwd command on many systems IS interactive
    and as such you can not do 'interactions' with it
    with the system command. What you will need to do
    is the bi-directional pipe solution:
    cf:
    <http://www.wetware.com/drieux/PR/blog2/Code/200311.html#id3152776334>

    ciao
    drieux

    ---

    Drieux Guest

Similar Threads

  1. File system commands
    By Trevor Barker in forum PHP Development
    Replies: 4
    Last Post: September 26th, 09:00 PM
  2. piped system commands
    By Andrew Gaffney in forum PERL Beginners
    Replies: 6
    Last Post: January 4th, 04:41 PM
  3. Running system commands
    By Nitin in forum PHP Development
    Replies: 3
    Last Post: September 24th, 11:56 AM
  4. system commands
    By yawnmoth in forum PHP Development
    Replies: 4
    Last Post: August 14th, 12:02 AM
  5. System() works on /usr/sbin commands
    By Tirumal B in forum PHP Development
    Replies: 0
    Last Post: July 31st, 06:13 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139