Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tips and tricks (was:Re: tlug: CDROM)



> When I have to do something more than twice, my brain kicks in
> and asks, "Should this be a shell script or alias?" The
> mount/unmount commands for both the CDROM and floppy drives
> ended up as shell scripts in /sbin. Yeah, it's still a pain to
> su to root to run them but it's better than nuttin'.

Shell scripts?  There rather short given you set up
/etc/fstab accordingly.  Furthermore, why don't you allow
non-root users to mount them (with restricted permissions of 
course)?  (I can't stand doing su, just to change a CDROM.)

> And don't forget you can automate a lot of stuff like telnet
> logins with expect; like this:
> 
> schweiz:~/bin$ cat teltlug
> #!/usr/bin/expect --
> 
> spawn telnet www.twics.com 
> expect "login: " 
> send "tlug\r"
> expect "Password:"
> send "****\r"
> expect "TERM = (vt100)"
> send "\r"
> expect "beehive:~$"
> interact

I am always quite reluctant to put a password into a script
(or any other file for that matter).  If anybody manages to
get into your machine, this provides the ticket to the next
one.

> My .bashrc files just keeps growin' and growin'. here's some of
> it: (hope you find something usefull in there and don't be shy
> about sharing *your* favorite alias with the group!)

How about this one:

  # ATTENTION: The string `cd' within the body of the definition of `orginal_cd'
  #            is not affected by the following alias (see decription of alias
  #            substitution in the bash-man-page), i.e. the original cd of the
  #            shell and not `my_cd' is executed.
  #	     Same with `pushd' and `popd'.
  #
  orginal_cd () { cd $* }
  alias cd=my_cd
  my_cd () { orginal_cd $*; set_prompt }
  orginal_popd () { popd $* }
  alias popd=my_popd
  my_popd () { orginal_popd $*; set_prompt }
  orginal_pushd () { pushd $* }
  alias pushd=my_pushd
  my_pushd () { orginal_pushd $*; set_prompt }

  set_prompt () { PS1="\h \u \! (`dirs|sed -e "s| .*||" -e "s|.*[^/]\(/[^/]*/[^/]*\)|...\1|"`): " }

Cheers,

Manuel

---------------------------------------------------------------
Next TLUG Nomikai: 11 March Wed 1998 Tengu TokyoEkiMae 19:30
Chuo-ku, Kyobashi 1-1-6, EchiZenYa Bld. B1/B2 03-3275-3691
Next TLUG Meeting: 11 April 1998 Saturday, Tokyo Station
Featuring Tague Griffith of Netscape i18n talking on source code
---------------------------------------------------------------
a word from the sponsor:
TWICS - Japan's First Public-Access Internet System
www.twics.com  info@example.com  Tel:03-3351-5977  Fax:03-3353-6096



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links