Sponsored Content
Top Forums Shell Programming and Scripting For loops with multiple variables Post 302507521 by Franklin52 on Thursday 24th of March 2011 05:55:29 AM
Old 03-24-2011
Not sure if this is what you're looking for, but it's unnecessary to use a temporary file for the userid.
You could do something like this:
Code:
MAXAGE=90

while IFS=: read uid dummy
do
  for j in `find /tcb -name "$uid" -exec ls -1 {} \;`
  do
    LASTPWCHG=`awk -F: '/u_succhg/{print $3}' "$j"`
    DAYSEC=86400
    DAWNOFTIME=`/usr/contrib/bin/perl -e 'print int(time)'`
    SECSAGO=`echo "$DAWNOFTIME - $LASTPWCHG" | bc`
    DAYSAGO=`echo "$SECSAGO/$DAYSEC" | bc`
    LEFTDAYS=`echo "$MAXAGE - $DAYSAGO" | bc`
    if [ "$LEFTDAYS" -le 7 ]
    then
       # show a reminder and send to user email address.... etc
    fi
  done
done < /etc/passwd

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Multiple for loops within a Menu?

I have program that I want to be able to use I guess you would call them functions.... to run muliple little programs or loops with one menu script. How would I do this. Here is some code I am using. Sorry about the formatting....it doesn't paste well. echo "*****************************... (3 Replies)
Discussion started by: darthur
3 Replies

2. UNIX for Dummies Questions & Answers

Variables being worked on inside of loops

I have a while read loop that reads values inside of a file and then performs an expr operation on each. Everything works fine, the way it's supposed to but, once the loop is finished, I can not access the variable that I used inside of the loop (but that variable was created outside of the... (7 Replies)
Discussion started by: yongho
7 Replies

3. Shell Programming and Scripting

scripting headache... loops & variables

Surely there's an easier way to do this, lets see if anyone knows! I am new to scripting so go easy on me! I have the following script and at the moment it doesn't work and I believe the problem is that I am using a while loop within a while loop. When I run the script using sh -x I can see... (6 Replies)
Discussion started by: StevePace
6 Replies

4. Shell Programming and Scripting

Multiple loops for Load test

Hi All, I am trying to write a bash script that will read a list of numbers from a file, then it needs to use netcat to create a socket connection and pass header/request. I need to limit it to 100 connections. So, after the first set of 100 are fineshed, I need to loop and do it again with... (0 Replies)
Discussion started by: willdev
0 Replies

5. Shell Programming and Scripting

while loops and variables under bash

Hi, This is probably going to be very simple but i came across something i can't quite explain. Here is the situation: i have a list of files, which i'd like to process one by one (get the size, make some tests, whatever) and generate some statistics using different variables. Something... (5 Replies)
Discussion started by: m69w
5 Replies

6. UNIX for Dummies Questions & Answers

While Loops Multiple File

Guru, I try to make a loop of 2 files, Input File1.txt: 1 2 File2.txt: A B C A, B and C is a file name, inside A X Y Z Expected Output A.1 X (2 Replies)
Discussion started by: guns
2 Replies

7. Shell Programming and Scripting

Two variables in output file name nested for loops

I am trying to use two nested for loops to process some files and then create a new file using both variables in the output file name. I have several files in this naming style: S1_L3_all_R1.fastq S1_L3_all_R2.fastq S1_L4_all_R1.fastq S1_L4_all_R2.fastq . . S1_L8_all_R1.fastq... (3 Replies)
Discussion started by: aminards
3 Replies

8. Shell Programming and Scripting

Unset variables in shell when it running two different loops

I have a script to start/stop/restart the tomcat application. When we run the script first time i.e stop/start it set all env variables(DISTRIB_ID,NAME,TOMCAT_CFG,....etc),but when we restart the tomcat it is running in the same shell.....I need to set the variables when i restart the tomcat(in the... (1 Reply)
Discussion started by: praveen265
1 Replies

9. Shell Programming and Scripting

Help with multiple for loops

All, I have set up ssh trust between 3 machines. The aim is to connect from machine-A to B and C and clear the txt files in tmp on all 3 machines. And, I have 3 environments and each environment has 2 hosts. So I should be able to run this script on any environment. Here is the logic: I want... (5 Replies)
Discussion started by: pnara2
5 Replies

10. Shell Programming and Scripting

Ssh to multiple hosts and then run multiple for loops under remote session

Hello, I am trying to login to multiple servers and i have to run multiple loops to gather some details..Could you please help me out. I am specifically facing issues while running for loops. I have to run multiple for loops in else condition. but the below code is giving errors in for... (2 Replies)
Discussion started by: mohit_vardhani
2 Replies
POSIX_GETEUID(3)							 1							  POSIX_GETEUID(3)

posix_geteuid - Return the effective user ID of the current process

SYNOPSIS
int posix_geteuid (void ) DESCRIPTION
Return the numeric effective user ID of the current process. See also posix_getpwuid(3) for information on how to convert this into a use- able username. RETURN VALUES
Returns the user id, as an integer EXAMPLES
Example #1 posix_geteuid(3) example This example will show the current user id then set the effective user id to a separate id using posix_seteuid(3), then show the difference between the real id and the effective id. <?php echo posix_getuid()." "; //10001 echo posix_geteuid()." "; //10001 posix_seteuid(10000); echo posix_getuid()." "; //10001 echo posix_geteuid()." "; //10000 ?> SEE ALSO
posix_getpwuid(3), posix_getuid(3), posix_setuid(3), POSIX man page GETEUID(2). PHP Documentation Group POSIX_GETEUID(3)
All times are GMT -4. The time now is 05:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy