လက်ရှိတည်နေရာ: ပင်မစာမျက်နှာ> ဖန်ရှင်အမျိုးအစားများ> shell_exec

shell_exec

command များကို shell 0 န်းကျင်မှတစ်ဆင့် Execute လုပ်ပြီး output ကို string တစ်ခုအဖြစ်ပြန်ပို့ပါ
အမည်:shell_exec
အမျိုးအစား:ပရိုဂရမ်ကွပ်မျက်
programming language:php
တစ်ကြောင်းဖြင့်အကျဉ်းချုပ်:သတ်မှတ်ထားသော shell command ကို execute လုပ်ပြီး command ၏ output ကို string တစ်ခုအဖြစ်ပြန်ပို့ပါ

function name: shell_exec ()

သက်ဆိုင်သောဗားရှင်း - PHP 4, PHP 5, PHP 7

function ကိုဖော်ပြချက် - shell_exec () function သည်သတ်မှတ်ထားသော shell command ကိုလုပ်ဆောင်ပြီး command ၏ output ကို string တစ်ခုအဖြစ်ပြန်ပေးသည်။ EXIC () function ကိုမတူဘဲ shell_exec () function သည်နောက်ဆုံးလိုင်းမျှသာမဟုတ်ဘဲ command output ၏ရလဒ်အပြည့်အစုံကိုပြန်ပို့သည်။

Syntax: shell_exec (string $ cmd): String | Null

Parametermer

  • $ CMD: လိုအပ်သော, ကွပ်မျက်ခံရဖို့လိုအပ်, shell command ကို။

Value ကိုပြန်သွားပါ

  • အကယ်. command ကိုအောင်မြင်စွာကွပ်မျက်ခံရပါက command မှ string ကိုရလဒ်မှထွက်လာသည်။
  • Command သည် execute လုပ်ရန်ပျက်ကွက်ပါကသို့မဟုတ် function ကိုမသန်စွမ်းပါက NULL ကိုပြန်လာသည်။

ဥပမာ 1:

 $output = shell_exec('ls -l'); echo "<pre>$output</pre>";

အထက်ပါဥပမာသည် "LS -l" command ကိုတင်ပြီးရလဒ်ကိုဒေါ်လာထုတ်လုပ်မှု variable ကိုသတ်မှတ်သည်။ ထို့နောက်ရလဒ်ကို browser မှရရှိသောရလဒ်မှ output လုပ်ရန် <pre> tag ကိုသုံးပါ။

ဥပမာ 2:

 $output = shell_exec('php -v'); echo "<pre>$output</pre>";

အထက်ဖော်ပြပါဥပမာသည် PHP ဗားရှင်းအချက်အလက်များကိုပြသမည်, PHP ဗားရှင်းအချက်အလက်များကိုပြသပြီးရလဒ်ကိုဒေါ်လာထုတ်လုပ်မှု variable ကိုသတ်မှတ်ပါ။ ထို့နောက်ရလဒ်ကို browser မှရရှိသောရလဒ်မှ output လုပ်ရန် <pre> tag ကိုသုံးပါ။

မှတ်စုများ

  1. shell_exec () function သည်အခွံပညတ်များကိုအကောင်အထည်ဖော်သည့်အခါ operating system ရရှိနိုင်မှုအပေါ်မူတည်သည်။
  2. လုံခြုံရေးအကြောင်းပြချက်များအတွက် shell_exec () function ကိုသတိနှင့်အတူအသုံးပြုသင့်ပြီးယုံကြည်စိတ်ချရသောပညတ်များကိုကွပ်မျက်ရန်ခွင့်ပြုထားသည်။
  3. shell_exec () function ကိုအသုံးပြုသောအခါ PHP configuration file တွင် function ကိုပိတ်ထားခြင်းမပြုရန်သေချာအောင်လုပ်ရန်လိုအပ်သည် (Disable_Functions configurations item)
  4. အချို့ဖြစ်ရပ်များတွင် '/ usr / bin / ls' ကဲ့သို့သော command များကိုလုပ်ဆောင်ရန်အကြွင်းမဲ့လမ်းကြောင်းကိုအသုံးပြုရန်လိုအပ်သည်။
  5. အကယ်. command သည်အသုံးပြုသူ input ကိုလိုအပ်ပါကအခြားလုပ်ဆောင်မှုများကို အသုံးပြု. အခြားလုပ်ဆောင်မှုများကိုသုံးပါ (ဥပမာ Eulex (Passthru) သို့မဟုတ် Passthru ()) function ကိုသုံးပါ။
သက်ဆိုင်သောဖင်ခှ်ရှင်းများ
  • command ကို execute လုပ်ပြီး input / output အတွက်အသုံးပြုသောဖိုင်ညွှန်ပြမှုကိုဖွင့်ပါ proc_open

    proc_open

    commandကိုexecuteလုပ
  • command များကို shell 0 န်းကျင်မှတစ်ဆင့် Execute လုပ်ပြီး output ကို string တစ်ခုအဖြစ်ပြန်ပို့ပါ shell_exec

    shell_exec

    commandများကိုshell0
  • လက်ရှိလုပ်ငန်းစဉ်၏ ဦး စားပေးပြောင်းလဲမှု proc_nice

    proc_nice

    လက်ရှိလုပ်ငန်းစဉ်၏ဦး
  • ပြင်ပပရိုဂရမ်များ Execute လုပ်ခြင်းနှင့် output ကိုပြသခြင်း system

    system

    ပြင်ပပရိုဂရမ်များExe
  • shell ကို Metacharacter Elae escapeshellcmd

    escapeshellcmd

    shellကိုMetacharacte
  • proc_open () function ကိုဖွင့်လှစ်သည့်လုပ်ငန်းစဉ်များအကြောင်းသတင်းအချက်အလက်များကိုရယူပါ proc_get_status

    proc_get_status

    proc_open()functionက
  • ပြင်ပပရိုဂရမ်တစ်ခုကိုလုပ်ဆောင်ပါ exec

    exec

    ပြင်ပပရိုဂရမ်တစ်ခုကိ
  • proc_open () မှဖွင့်လှစ်ခြင်းလုပ်ငန်းစဉ်ကိုပိတ်ပါ။ လုပ်ငန်းစဉ်ထွက်ပေါက်ကုဒ်ကိုပြန်သွားပါ proc_close

    proc_close

    proc_open()မှဖွင့်လှ
လူကြိုက်များသော ဆောင်းပါးများ