如何在Linux计算机上使用Python脚本添加用户 [英] How do I add users using Python scripts on a Linux machine

查看:297
本文介绍了如何在Linux计算机上使用Python脚本添加用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Linux机器上使用Python脚本添加用户?


有人有脚本吗?

解决方案

2007年1月1日11:33:42 -0800,Ramdas < ra **** @ gmail.comwrote:


>如何在Linux机器上使用Python脚本添加用户?
有人有脚本吗?



这应该像以下一样简单:


os.system(" / usr / sbin / useradd - m -d / home / newuser -s / bin / ksh")

Dan


这是用python编写的shell脚本层顶。是否有一个

特定的原因你必须使用python?为什么不使用shell,那是'

它的设计目的是什么?除非你有一些复杂的数学/网络

要求或顶部的东西。


-h


01 / 01/07,Daniel Klein< da *********** @ gmail.comwrote:


2007年1月1日11:33: 42-0800,Ramdas, < ra **** @ gmail.comwrote:


如何在Linux机器上使用Python脚本添加用户?


有人有脚本吗?



这应该像以下一样简单:


os.system(" / usr / sbin / useradd - m -d / home / newuser -s / bin / ksh")

Dan

-
http://mail.python.org/mailman/listinfo/python-list



-

Hari Sekhon


嗯,


我需要从Web界面为Web服务器添加用户,它只运行
$。我需要添加用户,设置配额,以及将来甚至看看管理IP表以限制带宽的



我知道os.system(),但是这必须通过表格输入来完成

通过网络界面。


无论如何,谢谢,建议是否有更多的pythonic解决方案


Ramdas

Hari Sekhon写道:


这是shell脚本,顶部有一个python层。是否有一个

特定的原因你必须使用python?为什么不使用shell,那是'

它的设计目的是什么?除非你有一些复杂的数学/网络

要求或顶部的东西。


-h


01 / 01/07,Daniel Klein< da *********** @ gmail.comwrote:


2007年1月1日11:33: 42-0800,Ramdas, < ra **** @ gmail.comwrote:


>如何在Linux机器上使用Python脚本添加用户?

>

>有人有脚本吗?



这应该像以下一样简单:


os.system(" / usr / sbin / useradd - m -d / home / newuser -s / bin / ksh")

Dan

-
http://mail.python.org/mailman/listinfo/python-list




-

Hari Sekhon


How do I add users using Python scripts on a Linux machine?

Someone has a script?

解决方案

On 1 Jan 2007 11:33:42 -0800, "Ramdas" <ra****@gmail.comwrote:

>How do I add users using Python scripts on a Linux machine?

Someone has a script?

This should be as easy as something like:

os.system("/usr/sbin/useradd -m -d /home/newuser -s /bin/ksh")

Dan


That is shell scripting with a python layer on top. Is there a
specific reason you have to use python? Why not just use shell, that''s
what it''s designed for? Unless you have some complex maths/networking
requirement or something on top.

-h

On 01/01/07, Daniel Klein <da***********@gmail.comwrote:

On 1 Jan 2007 11:33:42 -0800, "Ramdas" <ra****@gmail.comwrote:

How do I add users using Python scripts on a Linux machine?

Someone has a script?


This should be as easy as something like:

os.system("/usr/sbin/useradd -m -d /home/newuser -s /bin/ksh")

Dan
--
http://mail.python.org/mailman/listinfo/python-list


--
Hari Sekhon


Well,

I need to add users from a web interface for a web server, which runs
only Python. I need to add users, set quotas and in future even look at
managing ip tables to limit bandwidth.

I know os.system(), but this has to be done through a form entry
through a web interface.

Anyways thanks, do advise if there more pythonic solutions

Ramdas
Hari Sekhon wrote:

That is shell scripting with a python layer on top. Is there a
specific reason you have to use python? Why not just use shell, that''s
what it''s designed for? Unless you have some complex maths/networking
requirement or something on top.

-h

On 01/01/07, Daniel Klein <da***********@gmail.comwrote:

On 1 Jan 2007 11:33:42 -0800, "Ramdas" <ra****@gmail.comwrote:

>How do I add users using Python scripts on a Linux machine?
>
>Someone has a script?

This should be as easy as something like:

os.system("/usr/sbin/useradd -m -d /home/newuser -s /bin/ksh")

Dan
--
http://mail.python.org/mailman/listinfo/python-list



--
Hari Sekhon


这篇关于如何在Linux计算机上使用Python脚本添加用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆