linux - sudo in bash, permission denied -


i want block usb mass storage in of systems in lan. have written bash script modify file. running script default admin in ubuntu. script not able modify file. getting following error "bash: /etc/modprobe.d/blacklist.conf: permission denied"

below bash script

#/bin/bash password='mypassword'                  #admin password of remote system val='blacklist usb-storage'            #text want add in file sysname in $(cat systemdetails)    #systemdetails file stores ssh $sysname 'echo '$password' | sudo -s echo '$val ' >> /etc/modprobe.d/blacklist.conf' echo done #script ends 

note: have configured system such no ssh password required.

any pointers in regard helpful.

try this:

ssh $sysname "echo $password | sudo -s sh -c 'echo $val >> /etc/modprobe.d/blacklist.conf'" 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -