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
08-06-2002 08:44 AM
08-06-2002 08:44 AM
#!/bin/ksh
# Greets $LOGNAME or a specified user
#date=`data | cut -d\ -f4 |cut -d: -f1`
date=`date|awk '{print $4}'`
name=$1
if [ $# -eq 0 ]
then
name=`finger -s -m $LOGNAME | head -2 |tail -1 |awk '{print $2}'`
fi
if [ $date -le 1 $date -a 11 -ge $date ]
then
echo Good Morning, $name
fi
if [ $date -le 12 $date -a 17 -ge $date ]
then
echo Good Afternoon, $name
fi
if [ $date -le 18 $date -a 23 -ge $date ]
then
echo Good Evening, $name
fi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2002 08:49 AM
08-06-2002 08:49 AM
Re: script
if [ $date -ge 1 -a $date -le 11 ]
if [ $date -ge 12 -a $date -le 17 ]
if [ $date -ge 18 -a $date -le 23 ]
it reads like:
if $date greater than or equal to 1 and $date less than or equal to 11, then ....
Regards,
Kenneth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2002 08:49 AM
08-06-2002 08:49 AM
Re: script
Try to put echo statement in quotes
echo "Good Morning"
-USA..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2002 08:50 AM
08-06-2002 08:50 AM
Re: script
Flip around the test after the "-a"
What happens??
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2002 09:09 AM
08-06-2002 09:09 AM
Re: script
#!/bin/ksh
# Greets $LOGNAME or a specified user
#date=`data | cut -d\ -f4 |cut -d: -f1`
date=`date|awk '{print $4}'`
name=$1
if [ $# -eq 0 ]
then
name=`finger -s -m $LOGNAME | head -2 |tail -1 |awk '{print $2}'`
fi
if [ $date -ge 1 -a $date -le 11 ]
then
echo "Good Morning", $name!
fi
if [ $date -ge 12 -a $date -le 17 ]
then
echo "Good Afternoon", $name!
fi
if [ $date -ge 18 -a $date -le 23 ]
then
echo "Good Evening", $name!
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2002 09:13 AM
08-06-2002 09:13 AM
Solutionpereal - / # sh -x ./file
+ + awk {print $4}
+ date
date=18:26:02
+ name=
+ [ 0 -eq 0 ]
+ + finger -s -m root
+ head -2
+ awk {print $2}
+ tail -1
name=???
+ [ 18:26:02 -ge 1 -a 18:26:02 -le 11 ]
./file[12]: 18:26:02: Syntax error
+ [ 18:26:02 -ge 12 -a 18:26:02 -le 17 ]
./file[16]: 18:26:02: Syntax error
+ [ 18:26:02 -ge 18 -a 18:26:02 -le 23 ]
./file[20]: 18:26:02: Syntax error
pereal - / # finger -s -m root
Login Name TTY Idle When Bldg. Phone
root ??? *p1 Tue 18:25
or...
you could filter the name variable for all special characters....
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2002 09:14 AM
08-06-2002 09:14 AM
Re: script
date=`date|awk '{print $4}'`
then date will be something like hh:mm:ss, therefore it will have error when comparing with integer in line 12, 16, and 20.
Try change line 5 to:
date=`date|awk '{print $4}'|cut -d : -f 1`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2002 09:22 AM
08-06-2002 09:22 AM
Re: script
The issue is in setting the date parameter , this sets it to 13:14:50 which also includes the second too , I have modified it to the follwoing :
#!/bin/ksh -x
# Greets $LOGNAME or a specified user
#date=`data | cut -d\ -f4 |cut -d: -f1`
date=`date|awk '{print $4}'| cut -c 1-2`
name=$1
if [ $# -eq 0 ]
then
name=`finger -s -m $LOGNAME | head -2 |tail -1 |awk '{print $2}'`
fi
if [ $date -ge 1 -a $date -le 11 ]
then
echo Good Morning, $name
fi
if [ $date -le 12 $date -a 17 -ge $date ]
then
echo Good Afternoon, $name
fi
if [ $date -le 18 $date -a 23 -ge $date ]
then
echo Good Evening, $name
fi
this will work , also please use -x that is the debuuger mode so that you can exactly know waht the command is doing .
Manoj Srivastava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2002 09:26 AM
08-06-2002 09:26 AM
Re: script
I feel like I have to fix this before I go home now!
#!/bin/ksh
# Greets $LOGNAME or a specified user
#!/bin/ksh
# Greets $LOGNAME or a specified user
hour=$(date +'%H')
name=bob
if [ $hour -ge 18 ] ; then
echo "Good Evening", ${name}
exit 3
fi
if [ $hour -ge 12 ] ; then
echo "Good Afternoon", ${name}
exit 2
fi
if [ $hour -ge 1 ] ; then
echo "Good Morning", ${name}
exit 1
fi
---
the problem is with the -a option...
I'll work on it more,, sheesh my scripting has gone to the dogs..
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2002 09:28 AM
08-06-2002 09:28 AM
Re: script
#!/bin/ksh
# Greets $LOGNAME or a specified user
hour=$(date +'%H')
name=bob
if [ $hour -ge 18 -a $hour -lt 24 ] ; then
echo "Good Evening", ${name}
fi
if [ $hour -ge 12 -a $hour -lt 18 ] ; then
echo "Good Afternoon", ${name}
fi
if [ $hour -ge 1 -a $hour -lt 12 ] ; then
echo "Good Morning", ${name}
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2002 09:33 AM
08-06-2002 09:33 AM
Re: script
When run as root:
Good Morning, bin dev etc lib log net opt tmp usr var
pereal - / # echo ???
bin dev etc lib log net opt tmp usr var
pereal - / # finger -s -m root
Login Name TTY Idle When Bldg. Phone
root ??? *p1 Tue 18:25
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2002 10:17 AM
08-06-2002 10:17 AM
Re: script
#!/bin/ksh
# Greets $LOGNAME or a specified user
#date=`data | cut -d\ -f4 |cut -d: -f1`
date=`date|awk '{print $4}'|cut -d: -f1`
name=$1
if [ $# -eq 0 ]
then
name=`finger -s -m $LOGNAME | head -2 |tail -1 |awk '{print $2}'`
fi
if [ $date -ge 1 -a $date -le 11 ]
then
echo "Good Morning", $name!
fi
if [ $date -ge 12 -a $date -le 17 ]
then
echo "Good Afternoon", $name!
fi
if [ $date -ge 18 -a $date -le 23 ]
then
echo "Good Evening", $name!
fi