Sudo: menjalankan command di script

From OnnoWiki
Revision as of 10:35, 17 December 2018 by Onnowpurbo (talk | contribs)
Jump to navigation Jump to search

sumber: https://askubuntu.com/questions/425754/how-do-i-run-a-sudo-command-inside-a-script

Cara yang normal tambahkan sudo sebelum menjalankan script

sudo myscript.sh

Atau jika hanya salah satu command saja, bisa

sudo -u username "perintah"

Atau kalau mau memaksa, bisa

exec sudo su -c "perintah"


Jika di tanya password=

Tambahkan script

#! /bin/bash
read -s -p "[sudo] password for onno: " sudoPW
echo $sudoPW | sudo 'script.sh'

Referensi


Pranala Menarik