(E-Mail Removed) (Rejected) writes:
]I got my script to work using this syntax:
]#! /bin/ksh
]IP=`who am i | sed -e 's/^.*(//' -e 's/)//'`
]ME=`whoami`rps
]if [ "$IP" ]; then
] vi -c "/$ME.homelinux.com/d" -c "wq" /etc/hosts 1>/tmp/waste 2>&1
] echo "$IP $ME.homelinux.com" >>/etc/hosts
]fi
]BUT I still have the issue of multiple users editing the /etc/hosts
]file. Is there some way to enforce a lock, or a way to include a
]lists of hosts from /etc/hosts? Something like #include
]/etc/dynamichosts ?
]Again any help is appreciated.
](E-Mail Removed) (Rejected) wrote in message news:<(E-Mail Removed). com>...
]> Here is my dilemia: I have an RS6000 that has IP printers defined to
]> dynamic DNS addresses. The spooler won't do DNS lookups, so I have to
]> set the /etc/hosts file to have the DNS entries. To the user login
]> script I added
]>
]> export CLIENTIP=`who am i | sed -e 's/^.*(//' -e 's/)//'`
]>
]> This will set the unix environment variable of CLIENTIP each time a
]> user logs in. I then want to take this script (dyndns.sh) to update
]> the /etc/hosts file
]>
]> #! /bin/ksh
]> IP=$CLIENTIP
]> ME=`whoami`rps
]>
]> if [ "$IP" ]; then
]> sed '/^--$ME--/,/^--$ME--/'d /etc/hosts > /etc/hosts
]> echo "--$ME--\n$IP $ME.homelinux.com\n--$ME--" >>/etc/hosts
]> fi
]>
]> This would get tricky if multiple users login at the same time, so I
]> prefer not to create a new file, "> /etc/hosts" (like I'm currently
]> testing), but edit the existing file on the file.
Sure. Put in a lock yourself. YOu control that script. Have the script
create and read the lock.
]> I'm open to any and all solutions. Please help. Thanks.