From: "wbsurfver@..." Date: 2007-08-18T18:35:06+09:00 Subject: need help. want to use Net::sh to do sudo command I want to do a sudo command to change permissions on our server because our admin has some kind of build that blows away the image directory and it ends up having the wrong permissions after the build. When the sudo command is run it will prompt for a password and I need to write the password to it. If I just write to the stream before it prompts, I'm not sure if it will work ? Also if someone could give me the exact stuff that they think will work, that would be helpfull as I am concerned if I play with it and have failed attempts it might lock my account. I want to be able to email the group and say, 'hey here is a script that runs every 10 minutes from my pc and fixes the build problem", If possible, I don't want the admins to be upset with me for getting my account locked because I was playing around. Our server runs linux, thanks. Below is sort of what my script would do, but the password part is missing. As I said, it may be an easy thing, I'm just affraid of getting it wrong ... ----------------------------------------------------------------------- require 'net/ssh' host = 'myhost.frog.surf.com' Net::SSH.start( host, :password=>'candy', :port=>22, :username=>'ljkid' ) do |session| cmd = 'sudo chmod 777 /apps/mystuff/images' session.process.popen3(cmd) do |stdin,stdout,stderr| puts stdout.read end end