We have an ec2 instance running with django rest framework. Now, there I want to be able to run a crontab that initiates a python script that calls a php script.
test.py
class Command(BaseCommand):
def handle(self, *args, **options):
p = subprocess.Popen(['php', "/opt/python/current/app/my-app/my_test_file.php", name, caption], stdout=subprocess.PIPE)
result = p.communicate()[0]
Now on my local machine I get no errors whatsoever. It works fine. And as you can see I use an absolute path there.
When uploading to ec2 and running I get this error:
> File "/usr/lib64/python2.7/subprocess.py", line 522, in call > return Popen(*popenargs, **kwargs).wait() > File "/usr/lib64/python2.7/subprocess.py", line 710, in __init__ > errread, errwrite) > File "/usr/lib64/python2.7/subprocess.py", line 1335, in _execute_child > raise child_exception > OSError: [Errno 2] No such file or directory
What does this have to do with? Is it because of a php file that it can't find? Because I also used this method as well:
directory = os.getcwd()
p = subprocess.Popen(['php', directory + "/my_test_file.php", name, caption], stdout=subprocess.PIPE)
And that worked locally but again on ec2 gave that same error!
Please help! Thank You in advance!
Aucun commentaire:
Enregistrer un commentaire