Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to automate the process for my ftp user creation, however I need to be able to set the quota of a user via PHP, in a shell on a remote server, using SSH. I would use edquota username however is there a way to do this via PHP?

Here is console preview

[root@s1 home]# edquota user2

Disk quotas for user user2 (uid 509):
  Filesystem                   blocks       soft       hard     inodes     soft     hard
  /dev/simfs                     2820          0       4096          6        0     4096
~                                                                                                                                                        
~                                     

Now what i'd have to do is edit the amount of blocks, but how would I do this over ssh2_exec() ?

share|improve this question
    
SSH and FTP are networking protocols, how do you want to configure a quota with them? –  Lucas Kauffman May 2 '12 at 5:05
    
its configuring disk quota for a system user(ftp user) –  Saulius Antanavicius May 2 '12 at 5:06
    
You mean using a shell? –  Lucas Kauffman May 2 '12 at 5:11
    
Well i'd have to run edquota username then edit this with editor.. however I need to do this via SSH over PHP –  Saulius Antanavicius May 2 '12 at 5:12
    
Do you need to connect to a remote server or not? –  Lucas Kauffman May 2 '12 at 5:13

1 Answer 1

up vote 0 down vote accepted

You can use the exec method in php and use setquota instead of edquota:

exec("ssh yourserver.com 'setquota -u  username  2820  0 4096  6  0 -a /dev/simfs'");
share|improve this answer
    
Completely misunderstood my question. If you execute <edquote username> in console, it will open editor to change the quota and other settings, now where I would get stuck is actually making the change as it's not a file I can download locally, edit it via PHP and then upload back(or not as far as I know) I will update the post a little –  Saulius Antanavicius May 2 '12 at 5:26
    
Now I know what you want :) –  Lucas Kauffman May 2 '12 at 5:31
    
:D Sorry, been working for too many hours and it's 6.32am.. –  Saulius Antanavicius May 2 '12 at 5:32
    
updated my answer –  Lucas Kauffman May 2 '12 at 5:36
    
Seems to update 'soft' but not blocks? and I did change the '2820' I tried to add another zero after, didn't help either –  Saulius Antanavicius May 2 '12 at 5:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.