Sponsored Content
Top Forums Shell Programming and Scripting Help turning pseudocode into ksh script Post 302858759 by Leedor on Tuesday 1st of October 2013 10:30:15 AM
Old 10-01-2013
Help turning pseudocode into ksh script

Hi gurus,

My boss has asked me to create a unix script to check header files vs data files and to send an email in case of any failure.

I have very little unix scripting experience and it was now long ago so I'm a bit concerned I wont be able to turn this around by end of day tomorrow.

I've taken his requirements and turned it into a kind of pseudocode to help me design the script but now the exact Unix commands to use for each piece will require a lot of googling and testing on my part.

I am hoping that some kind person with years of experience will be able to turn this into ksh script for me in a matter of minutes

Code:
--------------- Main Procedure
Go to temp folder
Check for a header file matching mask: F57DWHDR.yyyymmddhhmmss.CSV
    If no header matching that mask <FAIL1>
    Else <CHECKHEADER>
<MOVEFILES>
--------------- Sub Procedures

<FAILn>
Email failure

<CHECKHEADER>
Check for all records ending in '*' (wc -l vs grep | wc -l?)
    If not equal <FAIL2>
    Else <CHECKFILES>

<CHECKFILES>
(LOOP THROUGH ALL LINES)
Read line: Filename, count (cut -c?)
Check for file existance
    If not exist <FAIL3>
    Else <CHECKCOUNT>
(ENDLOOP)

<CHECKCOUNT>
Compare readcount to filereccount
    if not equal <FAIL4>

<MOVEFILES>
Move file to current area already used by existing code

Here is an example header file, fixed width (50 C filename, 10 C count, ' *) = 62 chars.

Code:
F4211OPN20130916041521.CSV                        0000041216 *
F4201OPN20130916041558.CSV                        0000010212 *
F574211OPN20130916041652.CSV                      0000040874 *
F574201OPN20130916041703.CSV                      0000010212 *
F57DWHDR20130916041720.CSV                        0000000005 *

Any help with this would be ever so much appreciated, but if you all have better things to do I wont be offended and will crack on with this tomorrow morning!
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Turning off the CDE

I am running Solaris 9 and wanted the CDE stopped when my users login. Can this be done by adding something to the .profile? Basically when they login they should be at the command line and have to start the CDE themselves. Thanks (11 Replies)
Discussion started by: meyersp
11 Replies

2. Shell Programming and Scripting

executing a ksh script from another ksh script

Hi, I'm new to unix scripting.How can i call a script from another script. I have a.ksh and b.ksh .I have to call b.ksh from a.ksh after it is successfully exceuted. I tried using #!/bin/ksh -x in a.ksh and at the end i have used /path/b.ksh My problem is it is executing only a.ksh.it... (6 Replies)
Discussion started by: ammu
6 Replies

3. UNIX for Dummies Questions & Answers

Turning Echo off

Hi, Is there any way like in dos to turn the echo off in a script? i have some lines popping up that i dont wish to be viewed when i am unziping a file it brings up the message updating: log.txt (deflated 72%) and extracting: log.txt i dont want these be viewed. Andy (4 Replies)
Discussion started by: chapmana
4 Replies

4. Shell Programming and Scripting

tracing a ksh script within a ksh script

I normally trace a script with the ksh -x <script name> and redirect strderr to file. But if you have a script like the examble below...... vi hairy bear=`grep bear animals` if then ksh more_animals fi If I ksh -x hairy it won't trace "more_animals" unless I put a -x in it. Is... (1 Reply)
Discussion started by: shorty
1 Replies

5. UNIX for Advanced & Expert Users

Algorithm In Pseudocode

A) produce an algorithm in pseudocode and a flowchart that gets n from the user and calculate their sum. B) Write an algorithm in pseudocode and a flowchart that gets number x from he user and calculates x5 ( X to the power of %5). Calculate by using multiplication. ... (1 Reply)
Discussion started by: delsega
1 Replies

6. Solaris

Turning in.ftpd on and off

For two straight days someone was running in.ftpd in my server (apparently looking to break in) and when I would do "top" almost every line would read "in.ftpd". I had a unix sysadmin friend of mine shut it down and then start it back up in a day and a half and all seems OK for now. Here's what I... (1 Reply)
Discussion started by: thomi39
1 Replies

7. Solaris

Script for turning processes in etc/inetd.conf on and off

Anyone have a perl script that can be run via a web browser to turn ftp or telnet on and off in etc/inetd.conf ? Believe it or not but I ride a motorcycle a lot in the summer and carry a laptop in my saddlebags to connect from almost anywhere via Verizon alongside the highway. However, have too... (0 Replies)
Discussion started by: thomi39
0 Replies

8. Shell Programming and Scripting

import var and function from ksh script to another ksh script

Ih all, i have multiples ksh scripts for crontab's unix jobs they all have same variables declarations and some similar functions i would have a only single script file to declare my variables, like: var1= "aaa" var2= "bbb" var3= "ccc" ... function ab { ...} function bc { ... }... (2 Replies)
Discussion started by: wolfhurt
2 Replies

9. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

10. Shell Programming and Scripting

Turning on Debugging for a perl script

for security reasons I can not post any part of the script in question in this thread. i hope im not breaking any rules by not doing so. but i have a perl script that i've been asked to turn on debugging on. i didn't write this perl script and i have very very little knowledge of perl. so i... (3 Replies)
Discussion started by: SkySmart
3 Replies
times(1)                                                           User Commands                                                          times(1)

NAME
times - shell built-in function to report time usages of the current shell SYNOPSIS
sh times ksh times DESCRIPTION
sh Print the accumulated user and system times for processes run from the shell. ksh Print the accumulated user and system times for the shell and for processes run from the shell. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
ksh(1), sh(1), time(1), attributes(5) SunOS 5.10 15 Apr 1994 times(1)
All times are GMT -4. The time now is 11:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy