On Mon, 2012-04-30 at 13:53 +0300, Mucibirahman İLBUĞA wrote:

> #!/usr/bin/python
> # -*- coding: utf8 -*-
> import string, os, time, random
> 
> 
> sifre=str(random.random())
> 
> 
> sifre=sifre[-5:]
> 
> f=open('/root/sifre','w')
> 
> f.writelines(sifre+chr(10))
> 
> f.close()
> 
> 
> cmd='htpasswd -bc /var/.htpasswd FtpKullanici `cat /root/sifre`'
> os.system(cmd)
> 
> cmd='mail -s "Mevcut ftp sifresi..." [email protected] < /root/sifre'
> os.system(cmd)
> 
> cmd='mail -s "Mevcut ftp sifresi..." [email protected] < /root/sifre'
> os.system(cmd)
> 
> 
> 

Test etmedim ama ayni isi yapan php kodu da asagidadir,

#!/usr/bin/php

$sifre=rand(10000,99999);
$f=fopen('/root/sifre','w');

fwrite($f,$sifre+chr(10));
fclose($f);

$cmd='htpasswd -bc /var/.htpasswd FtpKullanici `cat /root/sifre`';
system($cmd);

$cmd='mail -s "Mevcut ftp sifresi..." [email protected] < /root/sifre';
system($cmd);

$cmd='mail -s "Mevcut ftp sifresi..." [email protected]
< /root/sifre';
system($cmd);

:) noktali virgul ve $ eklemek disinda pek fark olmadi goruldugu gibi.
-- 

/**
 * @author Atıf CEYLAN
 * Software Developer & System Admin
 * http://www.atifceylan.com
 */
_______________________________________________
Linux-programlama mailing list
[email protected]
https://liste.linux.org.tr/mailman/listinfo/linux-programlama
Liste kurallari: http://liste.linux.org.tr/kurallar.php

Cevap