hello Dan,

if you run the script as root then it is not problem to add an entry in a
read only file. you do not need to change permissions. here is a small
example of a script that will add an entry in your /etc/hosts file:

#! /bin/bash
HOSTSFILE=/etc/hosts
echo -n "Type the new host entry in the form {<ipaddress>  <hostname>}: "
read -e HOSTSENTRY
echo "$HOSTSENTRY" 1>>$HOSTSFILE

hope this helps

Stoyan

----- Original Message ----- 
From: "Dan O'Callaghan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 22, 2003 6:47 PM
Subject: [Solaris-Users] help with script


> Hi
> I'm writing a script to auto populate files for a jumpstart server.
> i.e. user inputs ip address, hostname and mac address and the /etc/hosts
> ethers and sysidcfg files are updates and/or created.
>
> How can I, from a script, populate an entry into /etc/hosts file when
> the file is read only access by default?
> I don't want to alter the default permissions.
> Manually I would just vi the file and exit with wq! , that would
> over-ride the read only permissions.
>
> Is there any way to force the entry in?
>
> Dan O'Callaghan
> Network and Systems Administrator
> Cogent Defence and Security Networks Ltd.
> Phone: 01633 292001
> Fax: 01633 292215
> e-mail: [EMAIL PROTECTED]
> Mobile: 0774 0670230
>
> ###########################################
>
> This message has been scanned by F-Secure Anti-Virus for Microsoft
> Exchange.
> For more information, connect to http://www.F-Secure.com/
>
> _______________________________________________
> Solaris-Users mailing list
> [EMAIL PROTECTED]
> http://www.filibeto.org/mailman/listinfo/solaris-users
>
>


_______________________________________________
Solaris-Users mailing list
[EMAIL PROTECTED]
http://www.filibeto.org/mailman/listinfo/solaris-users

Reply via email to