Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

QX
Hello all,

I am trying to fine tune my perl code here.

Now i am using just an systemcall to addusers but i've found out " q x` ` "
but i don't know how to add qx to the code below perhaps there is anyone
here to tell me how to ?

sub createuser(@) {
$username = shift;
$pwd      = shift;

system("adduser -g webusers -p $pwd -d $Userpath/$Domainname
\L$username\U");
chmod( 0750, "$Userpath/$Domainname" );
}



Report this thread to moderator Post Follow-up to this message
Old Post
Henk
07-29-04 08:55 AM


Re: QX
Henk wrote:
> I am trying to fine tune my perl code here.
>
> Now i am using just an systemcall to addusers but i've found out
> " q x` ` " but i don't know how to add qx to the code below
> perhaps there is anyone here to tell me how to ?
>
> sub createuser(@) {
>             $username = shift;
>             $pwd      = shift;
>
>             system("adduser -g webusers -p $pwd -d $Userpath/$Domainname
> \L$username\U");
>             chmod( 0750, "$Userpath/$Domainname" );
>             }

The qx// operator (or backticks) is explained in "perldoc perlop". Is
there anything there you don't understand?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
07-29-04 08:55 AM


Re: QX
Yes there is take the system("adduser blahblah");
should this be qx`("adduser blahblah")`; ???
and chown ? how must i do that ?

"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:2mka04FnpkgaU1@uni-berlin.de...
> Henk wrote: 
>
> The qx// operator (or backticks) is explained in "perldoc perlop". Is
> there anything there you don't understand?
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl



Report this thread to moderator Post Follow-up to this message
Old Post
Henk
07-29-04 08:55 AM


Re: QX
[ Please type your replies below the quoted part of the message you
respond to. Please do not quote the whole message, but only what's
appropriate to give context. ]

Henk wrote:
> Gunnar Hjalmarsson wrote: 

<code snipped>
 
>
> Yes there is take the system("adduser blahblah"); should this be
> qx`("adduser blahblah")`; ???

It should be e.g.

my $output = qx(adduser blahblah);

or

my $output = `adduser blahblah`;

i.e. don't surround the system command with doublequotes.

> and chown ? how must i do that ?

There is a built-in chown() function in Perl

perldoc -f chown

You probably need to run the program as root to be able to change file
ownership.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
07-29-04 08:55 AM


Re: QX
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:2mkb6aFni458U1@uni-berlin.de...
> [ Please type your replies below the quoted part of the message you
> respond to. Please do not quote the whole message, but only what's
> appropriate to give context. ]
>
> Henk wrote: 
>
> <code snipped>
> 
>
> It should be e.g.
>
>      my $output = qx(adduser blahblah);
>
> or
>
>      my $output = `adduser blahblah`;
>
> i.e. don't surround the system command with doublequotes.
> 
>
> There is a built-in chown() function in Perl
>
>      perldoc -f chown
>
> You probably need to run the program as root to be able to change file
> ownership.
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl

Ah Thank you.

I think i understand now.



Report this thread to moderator Post Follow-up to this message
Old Post
Henk
07-29-04 08:55 AM


Re: QX
Henk wrote:

> Now i am using just an systemcall to addusers but i've found out " q x` ` 
"
> but i don't know how to add qx to the code below perhaps

The useradd command does not produce any output, therefore using qx
will not be of any advantage.

Use system("command") if command interacts with the terminal.
Use $results=qx'command' to send output from command to a variable.

-Joe

Report this thread to moderator Post Follow-up to this message
Old Post
Joe Smith
07-29-04 08:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:27 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.