개발! 딱 깔끔하고 센스있게!

PHP 변수를 Bash 스크립트에 전달한 다음 시작하십시오. 본문

개발 스크랩 메모/PHP

PHP 변수를 Bash 스크립트에 전달한 다음 시작하십시오.

렉사이 2020. 11. 22. 00:00

그래서 기본적으로 이 bash 스크립트 실행:

#!/bin/bash path="./" filename="Ellly.blend" file=${path}${filename} description="Test of the api with a simple model" token_api="ff00ff" title="Uber Glasses" tags="test collada glasses" private=1 password="Tr0b4dor&3" curl -k -X POST -F "[email protected]${file}" -F "filenameModel=${filename}" -F "title=${title}" -F "description=${description}" -F "tags=${tags}" -F "private=${private}" -F "password=${password}" -F "token=${token_api}" https://api.sketchfab.com/v1/models 

php 함수에 있습니다.

문제는 내가 어떻게 변수를 전달할 것인지 모르겠고, php 함수를 회복하기 전에 그것을 끝날 때까지 기다린다는 것이다.

뭐 공부 해요?

대답

주의:나는 모든 설정을 하지 않았는데, 단지 네가 이해할 수 있기를 바란다.

옵션 1: 전달 인자

필리핀 피소:

$file = escapeshellarg($file); $filename = escapeshellarg($filename); // escape the others $output = exec("./bashscript $file $filename $tags $private $password"); 

맹격:

#!/bin/bash filename=$1 file=$2 description="Test of the api with a simple model" token_api="ff00ff" title="Uber Glasses" tags=$3 private=$4 password=$5 ... 

옵션 2: 환경 변수 사용

필리핀 피소:

putenv("FILENAME=$filename"); putenv("FILE=$file"); putenv("TAGS=$tags"); putenv("PRIVATE=$private"); putenv("PASSWORD=$PASSWORD"); $output = exec('./bash_script'); 

맹격:

filename=$FILENAME file=$FILE description="Test of the api with a simple model" token_api="ff00ff" title="Uber Glasses" tags=$TAGS private=$PRIVATE password=$PASSWORD ... 
Comments