shams Posted September 14, 2018 Share Posted September 14, 2018 (edited) 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 September 14, 2018 by shams Quote Link to comment Share on other sites More sharing options...
Zane Posted September 14, 2018 Share Posted September 14, 2018 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") Quote Link to comment Share on other sites More sharing options...
shams Posted September 15, 2018 Author Share Posted September 15, 2018 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? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted September 15, 2018 Share Posted September 15, 2018 The code you last posted. Is it the ACTUAL code, or did you re-type it here for us to see? Hint: sysetm ??? Quote Link to comment Share on other sites More sharing options...
shams Posted September 16, 2018 Author Share Posted September 16, 2018 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); ?> Quote Link to comment Share on other sites More sharing options...
Barand Posted September 16, 2018 Share Posted September 16, 2018 Try it with a closing quote. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted September 16, 2018 Share Posted September 16, 2018 OP - Amazing how error-prone you are. Two poorly posted code samples. A little review here and on your actual work might be the thing to help you out. Quote Link to comment Share on other sites More sharing options...
shams Posted September 16, 2018 Author Share Posted September 16, 2018 The original code is with the closing quote , mistake is in the post i forget to put the closing qoute: <?php system('/home/user/.getmail/getmail.sh'); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.