- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- scripting question
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
Forums
Discussions
Discussions
Discussions
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
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
02-13-2004 03:53 AM
02-13-2004 03:53 AM
Let me explain...
I have a script that cats a directory for find $SCRIPTS_DIR/reset_pass*.exp -print > /tmp/reset_pass.input
This file contains 4 entries reset_pass_user1 thru 4.
I then do a for loop on /tmp/reset_pass.input that does a number of commands.
What I would like to do, is there is another file created before hand that is associated to user1 throught 4. login_entry_user1, login_entry_user2, etc.
I want to try to do an I dont know if an if statement is the right way, but while going thru the for loop for reset_pass_user1,say, find the related file that was created, IE: login_entry_user1 and cat that file and place it in another file.
I hope I explained it right.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2004 04:00 AM
02-13-2004 04:00 AM
Re: scripting question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2004 04:09 AM
02-13-2004 04:09 AM
SolutionLet me see if I understood it right.
I would get the user name first from the reset_pass entry and then use it to identify
the login_entry.
For ex.,
for ENTRY in $(cat file)
do
USER=$(echo $ENTRY|awk '{FS="_";print $3}')
FILE=login_entry_${USER}
echo file is $FILE
done
In the above your FILE is login_entry_userx. So, you can anything you want with it. For ex., if [ -f $FILE ] etc.,
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2004 04:35 AM
02-13-2004 04:35 AM
Re: scripting question
$scripts=$ENV{"SCRIPTS_DIR"};
open(INP,"ls $scripts");
while(
chomp;
if (/(.+_)(.*)/) {
$a=$1; $b=$2;
if ($a eq "reset_pass_") {
($user)=split('\.',$b);
} elsif ($a eq "login_entry_") {
$user=$b;
} else {
$user="";
}
push(@{$hold{$user}},$_);
}
}
foreach $user (sort keys %hold) {
open(OUT,">/tmp/$user");
foreach $file (@{$hold{$user}}) {
open(FIL,"<$scripts");
while(
close(FIL);
}
close(OUT);
}
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2004 07:07 AM
02-13-2004 07:07 AM
Re: scripting question
1) '_' in your $SCRIPTS_DIR will result in nasty problems
2) $SCRIPTSDIR cannot be too long, or you'll run out of commandline length in the for statement
And I will go for a smaller program to cut your string... like Mark already mentioned. But I'm more a 'cut' fan.
My solution would be:
cat
do
USER=$(basename "$ENTRY" | cut -d_ -f3)
FILE=login_entry_${USER}
echo $FILE
done