PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, July 3, 2022

[FIXED] how do I get .php file variable to .py file

 July 03, 2022     localhost, localserver, php, python, xampp     No comments   

Issue

.php file code

<?php
$para1 = "one";
echo shell_exec("python C:/xampp/htdocs/python/test.py '$para1'");
?>

.py file code

#! C:\Users\mhammad\AppData\Local\Programs\Python\Python39\python.exe
print("Content-Type: text/html\n\r\n") #this code is for run .py file in xampp localserver.
import sys
print(sys.argv)

output of python file while running on xampp server in browser. ['C:/xampp/htdocs/python/test.py']

how do I get variable value from .php file to .py file.


Solution

This above mentioned code is working absolutely fine but the twist is that the xyz.py file is running in background on command line terminal and this print(sys.argv) can use the variable value $para1 = "one"; in xyz.py file and print the value of that shared variable. thanks



Answered By - Mangal Prasad Hammad
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing