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

java - Incorrect order of records in M-M relationship in hibernate -

command line - Use qwinsta in PowerShell ISE -

php - I want to create a website for polls/survey like this http://www.poll-maker.com/ -