water cooler :: shell script question



how can i automate logging in when i'm writing little shell scripts?  specifically, some examples would be to su to root, enter the root pwd and then do a find command on the whole filesystem.  another would be to run a vncviewer with a certain ip, and pipe in the password automatically.  

eg  #!/bin/sh
     vncviewer 192.168.1.102:3
      "pipe in password here for the vncauth window"

i know, i know.  this is dangerous, but i'm only going to do these types of things locally, behind a firewall

Code Sample
dsl@box:~$ vncviewer --help
VNC viewer version 3.3.7 - built Nov 16 2003 08:08:33
Copyright (C) 2002-2003 RealVNC Ltd.
Copyright (C) 1994-2000 AT&T Laboratories Cambridge.
See http://www.realvnc.com for information on VNC.

usage: vncviewer [<options>] <host>:<display#>
      vncviewer [<options>] -listen [<display#>]

<options> are standard Xt options, or:
             -shared
             -viewonly
             -fullscreen
             -passwd <passwd-file>
             -noauto
             -encodings <encoding-list> (e.g. "raw copyrect")
             -bgr233
             -owncmap
             -truecolour
             -depth <depth>


Please try to use the --help flag for a program before asking questions about run-time options, it usually has the info you need.

-J.P.

added for future reference....
some programs use "-help" or "-h" instead of "--help".

While we are on the subject, another way to get information is to search google for the man page of the program. In other words, search keywords like:

man vncviewer

My personal favorite for man pages is a site called die.net, so you can search via this syntax:

man vncviewer site:die.net

You're looking for `expect'.  Most people don't use expect anymore but, it used to be real handy for use with minicom to dial-up to your isp.

There's a bit of a learning curve (say ten to fifteen minutes) but you can automate a whole bunch of stuff with it.

I don't have a url for documentation, but a quick google should find some stuff.

Next Page...
original here.