Jump to content

Recommended Posts

I want to run the getmail  from php  code, this is the php code but it is not running the getmail:

<?php
chdir('/home/user/.getmail');
exec('./getmail.sh');
?>

getmail.sh and gmail-file are inside the '/home/user/.getmail' directory, i also tried the shell_exec() but not run the program, this is the getmail.sh code:

#!/bin/sh
/usr/bin/getmail --rcfile gmail-file

 

Edited by shams
Link to comment
https://forums.phpfreaks.com/topic/307688-problem-running-program-with-exec/
Share on other sites

The chdir function has everything to do with File I/O (fread,fclose,fwrite,etc) and nothing to do with the shell.

This is what your shell command should be like, according to your logic.

exec("/home/user/.getmail/.getmail.sh")

 

Thanks for reply i test the code it runs the bash scripts,  i created test.sh file with the content "this is a test file", and run with the code:

<?php
system('/home/user/tmp/test.sh');
?>

The code  printed the file to the browser successfully, but cannot start the linux applications like getmail and i tested for the filezilla with the code:

<?php
sysetm('/usr/bin/filezilla');
?>

  how to start the getmail with php?

This is the code i am trying to start the getmail from the php code in the ubuntu 18.04,  getmail.sh cat start the getmail from the gnome terminal but from php  code  bellow it cannot start the getmail:

<?php
system('/home/user/.getmail/getmail.sh);
?>

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.