- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script to add second email addr to .forward file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2004 03:19 AM
тАО06-14-2004 03:19 AM
I am a bit of a scripting newbie and wondered if someone could help me with a simple script I need to write.
I need to add a second email address into everyone's .forward file on a HP-UX 10.20 box we have (approx 300 users)
at the moment all they have is their email address joe.bloggs@ourcomp.com I would like to add in a second line:
joe.bloggs@ourothercomp.com after the first line.
I have figured out the logic, read in the current .forward, cut the username out, add the @domainname onto it and paste this back in. But have no idea what the syntax/best way of doing this is.
Many thanks in anticipation
Guy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2004 03:28 AM
тАО06-14-2004 03:28 AM
Re: script to add second email addr to .forward file
echo $user@ourothercomp >> ./.forward
Anil
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2004 03:30 AM
тАО06-14-2004 03:30 AM
Re: script to add second email addr to .forward file
Try something like this:
#!/usr/bin/sh
find /home -=name .forward | while read FNM; do
user=$(awk -F@ '{print $1}' $FNM)
echo "$user@ourothercomp.com" >> $FNM
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2004 03:32 AM
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2004 03:33 AM
тАО06-14-2004 03:33 AM
Re: script to add second email addr to .forward file
ls /home/*/.forward | while read file
do
name=`cat $line | awk -F"@" '{print $1}'`
echo "$name@othercompany.com" >> $file
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2004 03:42 AM
тАО06-14-2004 03:42 AM
Re: script to add second email addr to .forward file
#
open(listofforwards,"find /home -type f -name '.forward'|");
while(
$flname=$_;
$val=`cat $flname`;
chomp $val;
($fld1,$fld2) = split(/@/,$val);
$fld1 =~ s/$/\@YOUR_OTHER_DOMAIN/;
$doit=`echo $val > $flname`;
$doit=`echo $fld1 >> $flname`;
}
This assumes that there is ONLY one line in .forward
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2004 04:23 AM
тАО06-14-2004 04:23 AM
Re: script to add second email addr to .forward file
I went with Victor's second solution as it seemed the most comprehensible to me, thanks though to all that replied
Cheers
Guy