0

I have a custom codechecker in python, Also there is a bigger project running in PHP, which stores users code in MySQL database.

I am new to python, so I'm not sure how I can pass the code from PHP to Python.

Do I have to store the file to the filesystem to pass it to Python? (In that case too many files might be created, and their cleanup after execution has to be taken care)

2
  • What form does the code needing to be checked take? Can you provide an example? Commented Mar 9, 2012 at 4:25
  • code is any general C/C++, Java, Python code, which will take input from STDIN and output to STDOUT, as a example: #include<cstdio> int main() { int a; scanf("%d",&a); printf("%d\n",2*a); } Commented Mar 9, 2012 at 4:26

2 Answers 2

2

To expand on Brad's answer, there's several options, each with pros & cons...

  • Pipes (ie: STDIN/STDOUT): proc_open()
  • Shared memory: shmop_open()
  • AF_UNIX family sockets: socket_bind()

You'll probably want to use the first option but read up on the others before making a commitment.

Sign up to request clarification or add additional context in comments.

Comments

1

Just use STDIN/OUT.

See proc_open() to get at the pipes you need.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.