The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
shell program nivas Shell Programming and Scripting 8 02-21-2008 05:23 AM
shell program jyotiardeshana Shell Programming and Scripting 4 01-03-2006 06:51 AM
shell program rameshparsa Shell Programming and Scripting 1 11-17-2005 01:18 PM
C shell Program Reza Nazarian Shell Programming and Scripting 2 07-28-2003 03:52 PM
shell program nageshrc UNIX for Advanced & Expert Users 2 11-27-2001 12:32 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-17-2006
bebop1111116 bebop1111116 is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 30
very first shell program.

in the beginners book i have it gives an exercise to try. saying to make a script that examines the time. it should keep examining every second or so and say some sort of message. Can anyone help me get going.

Thanks

Last edited by bebop1111116; 09-17-2006 at 02:16 PM..
  #2 (permalink)  
Old 09-17-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,784

Code:
#!/bin/ksh
min=`date +%M`
sec=`date +%S`
# you now have minutes and seconds total seconds = seconds + ( minutes*60)
total=`echo "$sec + ($min * 60)" | bc`
# now you have total seconds... go from here

  #3 (permalink)  
Old 09-17-2006
bebop1111116 bebop1111116 is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 30
ok i think i have it written ok, how do you save it so i can run again later
  #4 (permalink)  
Old 09-17-2006
heru_90's Avatar
heru_90 heru_90 is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 65
make a file
I just use cat for make executable file

try this :

cat<<EOF>mytime
#!/bin/ksh
min=`date +%M`
sec=`date +%S`
echo ' "$sec + ($min * 60)" | bc '
EOF

chmod +x mytime

and then try to type mytime in u'r shell
Closed Thread

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:02 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0