UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old February 4th, 2005, 02:19 PM
chrs0302 chrs0302 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 43 chrs0302 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 30 sec
Reputation Power: 4
Script for timezone

Hi all

We have Production Sun servers with Solaris 9. On these servers the time zone is set for GMT. We are planning for a script which gives us the EST time on the same servers when executed.

Your tips/web site details/scripts are welcome.

Thanks

Reply With Quote
  #2  
Old February 4th, 2005, 04:29 PM
chrs0302 chrs0302 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 43 chrs0302 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 30 sec
Reputation Power: 4
Timezone

Pl refer my query and the output from date command on our system

bash-2.05$ date
Fri Feb 4 22:21:35 GMT 2005

I want to store one line awk script in a file which upon execution displays the output for the date command as

bash-2.05$ date
Fri Feb 4 17:21:35 EST 2005 (GMT = EST+5)

My awk string gives the flg o/p.

bash-2.05$ date | awk {'print $4'} | awk -F: {'print $1 -= 5'}
17

I want the o/p to be at least17:21:35 if not
Fri Feb 4 17:21:35 EST

Your help is appreciated.

Thanks

Reply With Quote
  #3  
Old February 4th, 2005, 05:01 PM
vgersh99 vgersh99 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 47 vgersh99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 Days 5 h 36 m 43 sec
Reputation Power: 4
Send a message via AIM to vgersh99 Send a message via MSN to vgersh99 Send a message via Yahoo to vgersh99
what will happen say at 2AM GMT time?

Reply With Quote
  #4  
Old February 5th, 2005, 05:32 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,083 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 33 m 4 sec
Reputation Power: 9
a) why do you assume people are using bash ?
b) why piping the awk ouput to an other awk ?
c) what if $1 (of your second awk) in < 5 ?
d) why not read man pages ? you could learn unix.

Reply With Quote
  #5  
Old February 7th, 2005, 09:58 AM
chrs0302 chrs0302 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 43 chrs0302 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 30 sec
Reputation Power: 4
Hi vgersh99

Now the EST here is 10:57AM on 7th Feb.

The out from date

bash-2.05$ date
Mon Feb 7 15:57:50 GMT 2005

Thanks

Reply With Quote
  #6  
Old February 7th, 2005, 10:00 AM
chrs0302 chrs0302 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 43 chrs0302 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 30 sec
Reputation Power: 4
Hi guggach

Quote:
Originally Posted by guggach
a) why do you assume people are using bash ?
b) why piping the awk ouput to an other awk ?
c) what if $1 (of your second awk) in < 5 ?
d) why not read man pages ? you could learn unix.


Hi guggach

Can you pl make your point 'c)' little clear?
I appreciate that.

Thanks.

Reply With Quote
  #7  
Old February 8th, 2005, 04:46 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,083 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 33 m 4 sec
Reputation Power: 9
Quote:
Originally Posted by chrs0302
Hi guggach

Can you pl make your point 'c)' little clear?
I appreciate that.

Thanks.


- when you write scripts NEVER assume a specific language
i know a lot of sys w/o bash and ksh
so write portabe, use the old good bourne, it runs on
EVERY *nix
- if you are writing 'bash' for performance, note 'shells' are NOT
performant, try perl or better.
- if you disturb 'awk', let it do the job, no need for a second one
and make checks, the line
Quote:
awk {'print $4'} | awk -F: {'print $1 -= 5'}

imo is simply bad, try something like
awk '{if(5 >$4) exit(1); print $4-5;}'
ensure $4 is an integer, c people call that: casting
awk '{if(5 >$4+0) exit(1), print $4-5;}'
or
awk '{if(5 >$4*1) exit(1), print $4-5;}'
NOTE: no need of 'else' statement, and the
notation: 1 >x and x< 1 are not really the same
working w/ other progs (awk is not concerned, but still a good
practice) the compiler will help you if you use the first one.
- manuals are my bible

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Script for timezone


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway