Skip to main content
added 1 character in body
Source Link
Blake Russo
  • 88
  • 1
  • 1
  • 7

I am creating a script where I can check to see if something is expired such as a kerberos ticket cache.

I need to get the expiration date/time, get the current date/time, and compare them to see if this first date/time would be expired.

I am creating a script to see if a kerberos ticket is still valid, or expired.

I can get the expiration date+time for both in epoch format (assuming that is best).

KRBEXPDATE=$(klist | grep -i krbtgt | awk '{print $3}')
KRBEXPTIME=$(klist | grep -i krbtgt | awk '{print $4}')
CURREPOCH=$(date +%s)
KRBEXPEPOCH=$(date --date="$KRBEXPDATE $KRBEXPTIME" +%s)

I want to see if the kerberos ticket is expired in an if statement, I am having trouble with the logic on if statement working with time. I may have answered my own question here, but should it be CURRENTEPOCH is greater than KRBEXPEPOCH then echo "ticket is not valid". Does this make sense?

if [[ "$CURREPOCH"$CURREPOCH" > "$KRBEXPEPOCH" ]] ;
then
  echo "Ticket is not valid"
fi

I am creating a script where I can check to see if something is expired such as a kerberos ticket cache.

I need to get the expiration date/time, get the current date/time, and compare them to see if this first date/time would be expired.

I am creating a script to see if a kerberos ticket is still valid, or expired.

I can get the expiration date+time for both in epoch format (assuming that is best).

KRBEXPDATE=$(klist | grep -i krbtgt | awk '{print $3}')
KRBEXPTIME=$(klist | grep -i krbtgt | awk '{print $4}')
CURREPOCH=$(date +%s)
KRBEXPEPOCH=$(date --date="$KRBEXPDATE $KRBEXPTIME" +%s)

I want to see if the kerberos ticket is expired in an if statement, I am having trouble with the logic on if statement working with time. I may have answered my own question here, but should it be CURRENTEPOCH is greater than KRBEXPEPOCH then echo "ticket is not valid". Does this make sense?

if [[ "$CURREPOCH > "$KRBEXPEPOCH" ]] ;
then
  echo "Ticket is not valid"
fi

I am creating a script where I can check to see if something is expired such as a kerberos ticket cache.

I need to get the expiration date/time, get the current date/time, and compare them to see if this first date/time would be expired.

I am creating a script to see if a kerberos ticket is still valid, or expired.

I can get the expiration date+time for both in epoch format (assuming that is best).

KRBEXPDATE=$(klist | grep -i krbtgt | awk '{print $3}')
KRBEXPTIME=$(klist | grep -i krbtgt | awk '{print $4}')
CURREPOCH=$(date +%s)
KRBEXPEPOCH=$(date --date="$KRBEXPDATE $KRBEXPTIME" +%s)

I want to see if the kerberos ticket is expired in an if statement, I am having trouble with the logic on if statement working with time. I may have answered my own question here, but should it be CURRENTEPOCH is greater than KRBEXPEPOCH then echo "ticket is not valid". Does this make sense?

if [[ "$CURREPOCH" > "$KRBEXPEPOCH" ]] ;
then
  echo "Ticket is not valid"
fi
Formatting, so we can see linebreaks. Use $(..) rather than `...`
Source Link

I am creating a script where I can check to see if something is expired such as a kerberos ticket cache.

I need to get the expiration date/time, get the current date/time, and compare them to see if this first date/time would be expired.

I am creating a script to see if a kerberos ticket is still valid, or expired.

I can get the expiration date+time for both in epoch format (assuming that is best). KRBEXPDATE=klist | grep -i krbtgt | awk '{print $3}' KRBEXPTIME=klist | grep -i krbtgt | awk '{print $4}' CURREPOCH=date +%s KRBEXPEPOCH=`date --date="$KRBEXPDATE $KRBEXPTIME" +%s

KRBEXPDATE=$(klist | grep -i krbtgt | awk '{print $3}')
KRBEXPTIME=$(klist | grep -i krbtgt | awk '{print $4}')
CURREPOCH=$(date +%s)
KRBEXPEPOCH=$(date --date="$KRBEXPDATE $KRBEXPTIME" +%s)

I want to see if the kerberos ticket is expired in an if statement, I am having trouble with the logic on if statement working with time. I may have answered my own question here, but should it be CURRENTEPOCH is greater than KRBEXPEPOCH then echo "ticket is not valid". Does this make sense?

if [[ "$CURREPOCH > "$KRBEXPEPOCH" ]] ;
then
  echo "Ticket is not valid"
fi

I am creating a script where I can check to see if something is expired such as a kerberos ticket cache.

I need to get the expiration date/time, get the current date/time, and compare them to see if this first date/time would be expired.

I am creating a script to see if a kerberos ticket is still valid, or expired.

I can get the expiration date+time for both in epoch format (assuming that is best). KRBEXPDATE=klist | grep -i krbtgt | awk '{print $3}' KRBEXPTIME=klist | grep -i krbtgt | awk '{print $4}' CURREPOCH=date +%s KRBEXPEPOCH=`date --date="$KRBEXPDATE $KRBEXPTIME" +%s

I want to see if the kerberos ticket is expired in an if statement, I am having trouble with the logic on if statement working with time. I may have answered my own question here, but should it be CURRENTEPOCH is greater than KRBEXPEPOCH then echo "ticket is not valid". Does this make sense?

if [[ "$CURREPOCH > "$KRBEXPEPOCH" ]] ;
then
  echo "Ticket is not valid"
fi

I am creating a script where I can check to see if something is expired such as a kerberos ticket cache.

I need to get the expiration date/time, get the current date/time, and compare them to see if this first date/time would be expired.

I am creating a script to see if a kerberos ticket is still valid, or expired.

I can get the expiration date+time for both in epoch format (assuming that is best).

KRBEXPDATE=$(klist | grep -i krbtgt | awk '{print $3}')
KRBEXPTIME=$(klist | grep -i krbtgt | awk '{print $4}')
CURREPOCH=$(date +%s)
KRBEXPEPOCH=$(date --date="$KRBEXPDATE $KRBEXPTIME" +%s)

I want to see if the kerberos ticket is expired in an if statement, I am having trouble with the logic on if statement working with time. I may have answered my own question here, but should it be CURRENTEPOCH is greater than KRBEXPEPOCH then echo "ticket is not valid". Does this make sense?

if [[ "$CURREPOCH > "$KRBEXPEPOCH" ]] ;
then
  echo "Ticket is not valid"
fi
Thanks is not required
Source Link
AReddy
  • 3.2k
  • 6
  • 37
  • 77

I am creating a script where I need tocan check to see if something is expired such as a kerberos ticket cache.

I need to get the expiration date/time, get the current date/time, and compare them to see if this first date/time would be expired.

I am creating a script to see if a kerberos ticket is still valid, or expired.

I can get the expiration date+time for both in epoch format (assuming that is best). KRBEXPDATE=klist | grep -i krbtgt | awk '{print $3}' KRBEXPTIME=klist | grep -i krbtgt | awk '{print $4}' CURREPOCH=date +%s KRBEXPEPOCH=`date --date="$KRBEXPDATE $KRBEXPTIME" +%s

I want to see if the kerberos ticket is expired in an if statement, I am having trouble with the logic on if statement working with time. I may have answered my own question here, but should it be CURRENTEPOCH is greater than KRBEXPEPOCH then echo "ticket is not valid". Does this make sense?

if [[ "$CURREPOCH > "$KRBEXPEPOCH" ]] ;
then
  echo "Ticket is not valid"
fi

Thanks in advance!

I am creating a script where I need to check to see if something is expired such as a kerberos ticket cache.

I need to get the expiration date/time, get the current date/time, and compare them to see if this first date/time would be expired.

I am creating a script to see if a kerberos ticket is still valid, or expired.

I can get the expiration date+time for both in epoch format (assuming that is best). KRBEXPDATE=klist | grep -i krbtgt | awk '{print $3}' KRBEXPTIME=klist | grep -i krbtgt | awk '{print $4}' CURREPOCH=date +%s KRBEXPEPOCH=`date --date="$KRBEXPDATE $KRBEXPTIME" +%s

I want to see if the kerberos ticket is expired in an if statement, I am having trouble with the logic on if statement working with time. I may have answered my own question here, but should it be CURRENTEPOCH is greater than KRBEXPEPOCH then echo "ticket is not valid". Does this make sense?

if [[ "$CURREPOCH > "$KRBEXPEPOCH" ]] ;
then
  echo "Ticket is not valid"
fi

Thanks in advance!

I am creating a script where I can check to see if something is expired such as a kerberos ticket cache.

I need to get the expiration date/time, get the current date/time, and compare them to see if this first date/time would be expired.

I am creating a script to see if a kerberos ticket is still valid, or expired.

I can get the expiration date+time for both in epoch format (assuming that is best). KRBEXPDATE=klist | grep -i krbtgt | awk '{print $3}' KRBEXPTIME=klist | grep -i krbtgt | awk '{print $4}' CURREPOCH=date +%s KRBEXPEPOCH=`date --date="$KRBEXPDATE $KRBEXPTIME" +%s

I want to see if the kerberos ticket is expired in an if statement, I am having trouble with the logic on if statement working with time. I may have answered my own question here, but should it be CURRENTEPOCH is greater than KRBEXPEPOCH then echo "ticket is not valid". Does this make sense?

if [[ "$CURREPOCH > "$KRBEXPEPOCH" ]] ;
then
  echo "Ticket is not valid"
fi
Source Link
Blake Russo
  • 88
  • 1
  • 1
  • 7
Loading