- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Help with script
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
07-03-2003 07:13 PM
07-03-2003 07:13 PM
Hi all,
In the script attached the var USER contain no data, maybe its a problem while reading the data.txt.
Anybody can help ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2003 07:55 PM
07-03-2003 07:55 PM
Re: Help with script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2003 08:02 PM
07-03-2003 08:02 PM
Re: Help with script
Your syntax looks correct to me.
What value is contained in the $USER_ASS variable prior to:
USER=`echo $USER_ASS|awk -F "-" '{print $1}'`
One thing that is possible is that the first field of the $USER_ASS has a "-". If this is the case you'll get nothing returned.
Also check further up, what's in data.txt??
Cheers
Con
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2003 08:05 PM
07-03-2003 08:05 PM
Re: Help with script
Hi,
Sorry !
The data.txt contains:
91838383;23/05/2003
91834383;22/07/2003
91838563;23/05/2003
91838383;03/09/2003
91838383;13/01/2003
34838383;23/05/2003
54838383;23/05/2003
91838381;25/12/2002
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2003 08:07 PM
07-03-2003 08:07 PM
Re: Help with script
Sorry again,
The correct is:
91838383-23/05/2003
91834383-22/07/2003
91838563-23/05/2003
91838383-03/09/2003
91838383-13/01/2003
34838383-23/05/2003
54838383-23/05/2003
91838381-25/12/2002
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2003 08:12 PM
07-03-2003 08:12 PM
Re: Help with script
It reads everything into DATA variable, the USER_ASS is empty.
Hence when you run
USER=`echo $USER_ASS|awk -F "-" '{print $1}'`
the $USER_ASS Variable is empty.
You need to insert a space before or after ";" in the data.txt file and it will work.
Cheers
Con
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2003 08:14 PM
07-03-2003 08:14 PM
Re: Help with script
Cheers
Con
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2003 08:23 PM
07-03-2003 08:23 PM
Re: Help with script
Change the line
awk -F ";" '{printf "%-9s-%-10s\n",$1,$2}' temp.txt > data.txt
to
awk -F ";" '{print $1, $2}' temp.txt > data.txt
This should fix your problem.
Cheers
Con
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2003 08:35 PM
07-03-2003 08:35 PM
Re: Help with script
cat data.txt | while read DATA USER_ASS
do
USER=`echo $USER_ASS|awk -F "-" '{print $1}'`
DATA_SISTEMA=`echo $DATA|awk -F "-" '{print $2}'`
to be:
cat data.txt | while read DATA
do
USER=${DATA%%-*}
DATA_SISTEMA=${DATA#*-}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2003 08:49 PM
07-03-2003 08:49 PM
Re: Help with script
Looked again at my previous post & realised you're using "-" as a field seperator, therefore the variable assignments for USER & DATA_SISTEMA do not need the '-F "-"' as part of the awk (white space is a default).
Cheers
Con
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2003 08:56 PM
07-03-2003 08:56 PM
Re: Help with script
Corn,
How to remove the / in the DATA and do the compare ?
Curtis,
Can you explain:
USER=${DATA%%-*}
DATA_SISTEMA=${DATA#*-}
Tks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2003 09:29 PM
07-03-2003 09:29 PM
SolutionNo points please.
Just a few ideas - I haven't tested any of this so might be wrong as before!!
I think you're talking about comparing the dates at the end of your script??
You can amend your script as:
......
#---echo $DATA
DATA_ATUAL=`date +%Y%m%d`
DATA_SISTEMA=`echo $DATA_SISTEMA |awk -F/ '{print $3$2$1}'`
if [ $DATA_ATUAL -gt $DATA_SISTEMA]
......
No need for the lines:
DATA2=`date +%d/%m/%Y`
#---echo $DATA2
Not sure if thats what you're after.
Cheers
Con
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2003 09:49 PM
07-03-2003 09:49 PM
Re: Help with script
Sorry Corn,
But you deserves it !!!
Tks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2003 10:43 PM
07-03-2003 10:43 PM
Re: Help with script
#
cat data.txt | while read DATA
do
# this is parameter expansion using substrings
#
# %% removes the large right pattern
# syntax is ${param%%pattern}
# example
# x=foo/fun/bar
# print ${x%%/*}
# foo
#
# # removes the small left pattern
# syntax is ${param#pattern}
# example
# cd $HOME/src/cmd
# print ${PWD#$HOME/}
# src/cmd
#
# USER = DATA with all characters removed from the right up to and including the first -, i.e. everything before the first -
#
# DATA_SISTEMA = DATA with all characters removed from the left up to and including the first -, i.e. everything after the first -
#
#
USER=${DATA%%-*}
DATA_SISTEMA=${DATA#*-}