Sponsored Content
Full Discussion: Ksh(Unix Distro) script
Top Forums Shell Programming and Scripting Ksh(Unix Distro) script Post 302348797 by Demon002 on Saturday 29th of August 2009 07:29:15 PM
Old 08-29-2009
Ksh(Unix Distro) script

ok so i am writing in VI.

Basically i am writing a script which does the following

1.) creates a file name as:
Code:
`hostname.`date '+%d%m%y_%H%M'.1.html

2.) echos some html tags >> to the same file name
3.) takes info from command showrev -p and then >> to the same file
4.) echos closing html tags and then >> to the same file

The issue is, This is for log keeping purposes, so i want to include the time, so that when the time changes the patch info will be spit into files per data/time for easy referencing. but if the script runs between changes in time i get two halves of the file seperate instead of 1 complete file

work around?

---------- Post updated at 01:29 PM ---------- Previous update was at 12:37 PM ----------

OK i guess im being too vague... lemme type this beast out...

Code:
 
#! /bin/ksh
 
 
touch `hostname`.`date '+%d%m%y_%Hhr%Mmin'`.PATCHES.html
 
echo "<html><body><pre width=pahe>" >>`hostname`.`date '+%d%m%y_%Hhr%Mmin'`.PATCHES.html
 
echo "PATCHES" >>`hostname`.`date '+%d%m%y_%Hhr%Mmin'`.PATCHES.html
 
echo "----------" >>`hostname`.`date '+%d%m%y_%Hhr%Mmin'`.PATCHES.html
 
showrev -p >>`hostname`.`date '+%d%m%y_%Hhr%Mmin'`.PATCHES.html
 
echo "</pre></body></html>" >>`hostname`.`date '+%d%m%y_%Hhr%Mmin'`.PATCHES.html

SO my problem again is it makes 2 files during the time change, How can i redirect the info into the file just created. Do i need to set the time of the script running to a variable, then reference the file redirect to the variable? or should i just be lazy and drop the time portion of date all togather.

Work around?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting an OpenVms .com to a UNIX ksh script

Does anyone know what a unix equivalent to the following OpenVms string would be? variable1 = F$FAO("!123AS",file_create_time) I can't seem to find the proper syntax of anything I try. Thx! J (1 Reply)
Discussion started by: prosserj
1 Replies

2. Shell Programming and Scripting

sending email from KSH unix script.

Hi Need guidance on including code to mail a couple of files atached with some subject and mail body !!.. Thanks in advance (3 Replies)
Discussion started by: rosh0623
3 Replies

3. UNIX for Dummies Questions & Answers

Live Unix Distro Help...

Hello, I was just looking for some help on Unix distros that don't affect my hard disk. Basically what I am looking for is a distro that has all your programming needs (so I can program in Unix) and the basic functions of an OS. I would also like it to include python if possible. BTW, is it... (0 Replies)
Discussion started by: vhab
0 Replies

4. Shell Programming and Scripting

how to convert unix .ksh script to windows .batch script

I am using awk in my .ksh script but when I am trying to run in windows its not recognising awk part of the ksh script , even when I changed it to gawk it does not work, this is how my .ksh and .bat files look like. thanx. #!/bin/ksh egrep -v "Rpt 038|PM$|Parameters:|Begin |Date: |End... (1 Reply)
Discussion started by: 2.5lt V8
1 Replies

5. UNIX for Dummies Questions & Answers

help to choose unix distro

what unix could you advice to me for following purposes? -browsing web -reading text information -listening to music (mp3/ogg/tracker modules) -watcing movies (rare) (9 Replies)
Discussion started by: spacevoid8
9 Replies

6. Fedora

Recommendations on Unix Distro

I'd like to become more familiar with Unix. To that end I want to install and practice/play with a (open source) Unix distro; however, I'm uncertain which one I should use. I'm considering freebsd, openbsd, and openSolaris. I'm familiar and comfortable with RHL/CentOS and Debian/Ubuntu. Keeping... (3 Replies)
Discussion started by: NateKin
3 Replies

7. UNIX for Dummies Questions & Answers

Help with ksh script to list files, cp it to another UNIX server

Hi, I'm quite new to ksh scripting, can someone help me with this. Requirements: I need to create a script that list the files from a user input date range. e. g. format of file: *c1*log.2012-12-22-14-00* *c1*log.2012-12-22-14-00* *c1*log.2012-12-22-14-00*... (7 Replies)
Discussion started by: chococrunch6
7 Replies

8. UNIX for Dummies Questions & Answers

UNIX ksh Copy Files Script

I need a UNIX ksh script that counts the number of files in directory, if the files exceed 20 files, then email results. I want the script to run every hour.. I don't have access to cron.. I'm some what new to UNIX. Windows guy all my career.. this is what I have so far.. #!/bin/ksh # count.sh ... (5 Replies)
Discussion started by: PerlHaven2k
5 Replies

9. Ubuntu

How to lock a file through UNIX KSH shell script?

I wrote two shell scripts in UNIX that renames the same file and scheduled them at the same time. The following are the steps that I followed:- 1. I wrote 2 scripts named s1.sh and s2.sh, both trying to add “exec_” prefix to the name of the files present in a folder i which already don't start... (4 Replies)
Discussion started by: piuli
4 Replies

10. What is on Your Mind?

Video: What is Your Favorite Linux Distro? UNIX.com and Primis

Video: What is Your Favorite Linux Distro? UNIX.com and Primis https://youtu.be/doa9sA6q9Uw With so many great flavors of Linux to choose from, we asked our UNIX.com members what is their favorite Linux distro and why. Here are the results: What is your favorite Linux distro? ... (0 Replies)
Discussion started by: Neo
0 Replies
DATETIME.SETISODATE(3)							 1						    DATETIME.SETISODATE(3)

DateTime::setISODate - Sets the ISO date

       Object oriented style

SYNOPSIS
public DateTime DateTime::setISODate (int $year, int $week, [int $day = 1]) DESCRIPTION
Procedural style DateTime date_isodate_set (DateTime $object, int $year, int $week, [int $day = 1]) Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates. PARAMETERS
o $object -Procedural style only: A DateTime object returned by date_create(3). The function modifies this object. o $year - Year of the date. o $week - Week of the date. o $day - Offset from the first day of the week. RETURN VALUES
Returns the DateTime object for method chaining or FALSE on failure. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | Changed the return value on success from NULL to | | | DateTime. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 DateTime.setISODate(3) example Object oriented style <?php $date = new DateTime(); $date->setISODate(2008, 2); echo $date->format('Y-m-d') . " "; $date->setISODate(2008, 2, 7); echo $date->format('Y-m-d') . " "; ?> Procedural style <?php $date = date_create(); date_isodate_set($date, 2008, 2); echo date_format($date, 'Y-m-d') . " "; date_isodate_set($date, 2008, 2, 7); echo date_format($date, 'Y-m-d') . " "; ?> The above examples will output: 2008-01-07 2008-01-13 Example #2 Values exceeding ranges are added to their parent values <?php $date = new DateTime(); $date->setISODate(2008, 2, 7); echo $date->format('Y-m-d') . " "; $date->setISODate(2008, 2, 8); echo $date->format('Y-m-d') . " "; $date->setISODate(2008, 53, 7); echo $date->format('Y-m-d') . " "; ?> The above example will output: 2008-01-13 2008-01-14 2009-01-04 Example #3 Finding the month a week is in <?php $date = new DateTime(); $date->setISODate(2008, 14); echo $date->format('n'); ?> The above examples will output: 3 SEE ALSO
DateTime.setDate(3), DateTime.setTime(3). PHP Documentation Group DATETIME.SETISODATE(3)
All times are GMT -4. The time now is 07:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy