1748089 Members
4772 Online
108758 Solutions
New Discussion юеВ

Re: Error Token 13585

 
SOLVED
Go to solution
Andrew Kaplan
Super Advisor

Error Token 13585

Hi there --

I have a password notification script running on one of our systems, and for some reason the following error message appears whenever it is run:

/root/password_notify: line 8: 13517
13585 : syntax error in expression (error token is "13585 ")

The script in question is listed below, and line 8 begins with the text last_change:

#!/bin/bash

users=`grep -v ":\!\!:" /etc/shadow|grep -v ":\*:" |grep -v root|cut -f1 -d:` expire_time=90 today=$((`perl -le 'print time'` / 86400 ))

for user in $users ; do
last_change=$(( `grep $user /etc/shadow |cut -f3 -d:` ))
days_left=$(( $expire_time - $today + $last_change )) if [ $days_left -lt 15 -a $days_left -ge 0 ]; then
mail -s "Your password on the Hadron server will expire in $days_left days." $user << EOF Hello, Your password of account $user, which is used for accessing the e-mail server on host `uname -n`, will expire in $days_left days.

Please update your password. If you have any questions, please contact at extension x-yzab or e-mail him at for help.

Thanks for your support!

EOF


fi
done


Can someone tell me what the error message means, and what I need to do to correct it? Thanks.
A Journey In The Quest Of Knowledge
2 REPLIES 2
Matti_Kurkela
Honored Contributor
Solution

Re: Error Token 13585

It would seem that the "grep" command on line 8 has produced two hits instead of one, namely:
13517
13585

Let me guess: you have two users so that one username is a substring of the other, right?
For example, "foo" and "foobar". This (or something similar) caused "grep" to produce a two-line output.

When grepping users from /etc/passwd or /etc/shadow, never do just "grep $user". Instead, you'd better do something like:
grep "^${user}:"
to specify that you'll want to match the username exactly: substring matches in the username and matches elsewhere on the line (gecos information!) are not accepted. If you don't do this, you'll get bitten sooner or later.

You can simulate this situation by typing this on the command line (after backslash, press Enter):
last_change=$(( 13517 \
13585 ))

This will produce the error message:
bash: 13517 13585 : syntax error in expression (error token is "13585 ")

which matches what you got from your script.
MK
Andrew Kaplan
Super Advisor

Re: Error Token 13585

Hi there --

I made the change you suggested to the script, and when it was rerun, it did not return an error message. I will keep an eye on it, and if there are any further problems, I'll let you know. Thanks.
A Journey In The Quest Of Knowledge