Sponsored Content
Full Discussion: Help with Korn Shell script
Operating Systems AIX Help with Korn Shell script Post 93440 by heprox on Monday 19th of December 2005 01:01:27 PM
Old 12-19-2005
Question Help with Korn Shell script

I have this Korn shell script that runs via a cron entry. It runs in a loop "watching" a specific file system for files with a certain name. The file system that it is watching is an upload file system for an FTP server. When files that are the correct name come in, it takes the extension of the file and runs several other scripts against the file with the extension as a vairable. The script looks like:

Code:
#!/bin/ksh
 
#
# Function : is_file_arrived file
# Arg(s)   : file = file to verify
# Output   : None
# Status   : 0 = yes file arrived, 1 = no
# Env.     : IFA_WAIT : interval (secs) for file size check (def=5)
#
 
is_file_arrived() {
   [ -z "$1" ] && return 1
   local file=$1
   local arrived=1
   local size1 size2
   if [ -f "$file" -a -z "$(fuser $file 2> /dev/null)" ] ; then
      size1=$(ls -l $file 2>/dev/null | awk '{print $5}')
      sleep ${IFA_WAIT:-15}
      size2=$(ls -l $file 2>/dev/null | awk '{print $5}')
      [ ${size1:-1} -eq ${size2:-2} ] && arrived=0
   fi
   return $arrived
}
 
 
processFile ()
{
   local fileName=$1
   local fileExtension=$2
   local fileNewName="/ftp/datafiles/str${fileExtension}.asc"
   local filePrintPath="/ftp/print"
   local fileTmpPath="/ftp/tmp"
   local fileODIName="str${fileExtension}.pos"
   mv -Eignore $fileName $fileNewName      # Add status check
   prepup $fileNewName $fileExtension
   mv -Eignore  $filePrintPath/$fileODIName $fileTmpPath/$fileODIName
   save2tmp $fileExtension
   call_siu $fileExtension
}
 
# Main Processing
 
nsec=1
#hile :
while [[ "$(date +%H%M)" -lt 2329 ]]
do
   for fileName in /ftp/datafiles/UPLOAD.[0-9][0-9][0-9][0-9]
   do
      fileExtension=${fileName#*.}
      is_file_arrived "$fileName" && nsec=1 && processFile $fileName $fileExtens
ion
   done
   sleep $nsec
   case $nsec in
      1)   nsec=15;;
      15)  nsec=45;;
      45)  nsec=90;;
      90)  nsec=300;;
      300) nsec=600;;
      600) nsec=900;;
      *)   nsec=1800;;
   esac
done

... the problem is that I keep getting files that are "stuck" in the /ftp/datafiles file system. The log from the crontab states that these files have the incorrect permission for the script to process them? The wierd thing is that it happens after the script initially renames them to "str####.asc" so the cron user (which has permissions to the filesystem and the files intially) was able to rename them? The log looks like:

Code:
+ is_file_arrived /gers/genret/datafiles/UPLOAD.0043
+ nsec=1
+ processFile /gers/genret/datafiles/UPLOAD.0043 0043
mv: 0653-401 Cannot rename /gers/genret/print/str0043.pos to /gers/genret/tmp/str0043.pos:
             A file or directory in the path name does not exist.
mv: /gers/genret/datafiles/str0043.asc: The file access permissions do not allow
 the specified action.

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

korn shell script

hello., i have 2 files.. 1 file is in this folder /home/test/ssk/DSA.WLG.20050713211544.20050710.20050713211544 (this part) other file is in this folder /home/kk/dev/DSA.WLG.20050711210100.20050710.20050711210100 ... (1 Reply)
Discussion started by: pavan_test
1 Replies

2. UNIX Desktop Questions & Answers

korn shell script

hi all i am writing the korn shell script. i have a SQL script which gives me the folowing output DSA.WLG.20050713211544.20051025.20050713211544 28991 1130198400 DSA.WLG.20050713211544.20051025.20050713211544 25881 1130198400 DSA.WLG.20050711210100.20051025.20050711210100 25881 ... (3 Replies)
Discussion started by: pavan_test
3 Replies

3. Shell Programming and Scripting

Korn Shell script not running

I am sorry, this is really trivial, yet I am not able to understand what the problem is! I am using korn shell and running this script #!/bin/ksh keep=3 while ; do echo $keep keep=$(($keep-1)) done I am getting this error: `keep=$' unexpected I am not able to understand it because ... (1 Reply)
Discussion started by: Asty
1 Replies

4. Shell Programming and Scripting

Korn shell interactive script

Hi, How can I prompt a user for two input and pass the input to variables in the script. I have the following script but it is not working: +++++++++Begin+++++++++++ #!/bin/sh database_c=$1 output_f=$2 echo "Your db is $1\nOutput is $2" +++++++++End+++++++++++ Thanks, Leonard (3 Replies)
Discussion started by: leonard905
3 Replies

5. Shell Programming and Scripting

Korn Shell Script

I have to solve some exercises in Korn Shell, but i'm having some problems. For example: Write a korn shell script with an alfanumeric string as argument. The script lists the file's names in the current directory that contain the given string as substring and that can be read and written. I... (3 Replies)
Discussion started by: burm
3 Replies

6. Homework & Coursework Questions

Korn Shell Script

1. The problem statement, all variables and given/known data: Write a korn shell script with an alfanumeric string as argument. The script lists the file's names in the current directory that contain the given string as substring and that can be read and written. 2. Relevant commands, code,... (3 Replies)
Discussion started by: burm
3 Replies

7. Shell Programming and Scripting

korn shell script guidance

Please look over my short comings during this line if questions. I have multiple lines in a file that look like, phycook 618722 1 76 12:15:13 pts/122 70:24 /4js/runtime2.02.10/lib/fglrun-bin initmenu.42r phycook 593484 1 65 12:15:18 pts/122 69:22... (3 Replies)
Discussion started by: juredd1
3 Replies

8. Shell Programming and Scripting

pass null value to sql script from korn shell script

There are 4 parameters that I have to pass from korn shell to sql script. 1) I have to check if $1 , $2 , $3 and $4 are null values or not . How can I do that ? 2) Once its determined that these values are null (in the sense they are empty) how can I pass null values to sql script... (11 Replies)
Discussion started by: megha2525
11 Replies

9. Shell Programming and Scripting

Need urgent help with korn shell script

Hi All, Need urgent help with korn shell script, which monitors AIX WPARs Status. Basically WPARs run on a LPAR, So there is a Command "lswpar" which displays WPARs status. This script should be checking the WPARs Status and email support if WPAR is down or broken. General lswpar output is as... (3 Replies)
Discussion started by: aix_admin_007
3 Replies

10. Shell Programming and Scripting

Help with improving korn shell script

I am primarily a SQA/Tester and new to korn shell. How can I improve the following script? #/bin/ksh SourceLocation=~/Scripts/Test/Source TrackerLocation=~/Scripts/Test/Tracker TargetLocation=rdbusse@rdbmbp:/Users/rdbusse/Scripts/Test/Target for file in $(cd $SourceLocation; ls) do ... (7 Replies)
Discussion started by: bayouprophet
7 Replies
ldns(3) 						     Library Functions Manual							   ldns(3)

NAME
ldns_dnssec_name_new, ldns_dnssec_name_new_frm_rr, ldns_dnssec_name_free, ldns_dnssec_name_name, ldns_dnssec_name_set_name, ldns_dnssec_name_set_nsec, ldns_dnssec_name_cmp, ldns_dnssec_name_add_rr, ldns_dnssec_name_find_rrset, ldns_dnssec_name_print SYNOPSIS
#include <stdint.h> #include <stdbool.h> #include <ldns/ldns.h> ldns_dnssec_name* ldns_dnssec_name_new(); ldns_dnssec_name* ldns_dnssec_name_new_frm_rr(ldns_rr *rr); void ldns_dnssec_name_free(ldns_dnssec_name *name); ldns_rdf* ldns_dnssec_name_name(ldns_dnssec_name *name); void ldns_dnssec_name_set_name(ldns_dnssec_name *name, ldns_rdf *dname); void ldns_dnssec_name_set_nsec(ldns_dnssec_name *name, ldns_rr *nsec); int ldns_dnssec_name_cmp(const void *a, const void *b); ldns_status ldns_dnssec_name_add_rr(ldns_dnssec_name *name, ldns_rr *rr); ldns_dnssec_rrsets* ldns_dnssec_name_find_rrset(ldns_dnssec_name *name, ldns_rr_type type); void ldns_dnssec_name_print(FILE *out, ldns_dnssec_name *name); DESCRIPTION
ldns_dnssec_name_new() Create a new data structure for a dnssec name Returns the allocated structure ldns_dnssec_name_new_frm_rr() Create a new data structure for a dnssec name for the given RR rr: the RR to derive properties from, and to add to the name ldns_dnssec_name_free() Frees the name structure and its rrs and rrsets. Individual ldns_rr records therein are not freed name: the structure to free ldns_dnssec_name_name() Returns the domain name of the given dnssec_name structure name: the dnssec name to get the domain name from Returns the domain name ldns_dnssec_name_set_name() Sets the domain name of the given dnssec_name structure name: the dnssec name to set the domain name of dname: the domain name to set it to. This data is *not* copied. ldns_dnssec_name_set_nsec() Sets the NSEC(3) RR of the given dnssec_name structure name: the dnssec name to set the domain name of nsec: the nsec rr to set it to. This data is *not* copied. ldns_dnssec_name_cmp() Compares the domain names of the two arguments in their canonical ordening. a: The first dnssec_name to compare b: The second dnssec_name to compare Returns -1 if the domain name of a comes before that of b in canonical ordening, 1 if it is the other way around, and 0 if they are equal ldns_dnssec_name_add_rr() Inserts the given rr at the right place in the current dnssec_name No checking is done whether the name matches name: The ldns_dnssec_name to add the RR to rr: The RR to add Returns LDNS_STATUS_OK on success, error code otherwise ldns_dnssec_name_find_rrset() Find the RRset with the given type in within this name structure name: the name to find the RRset in type: the type of the RRset to find Returns the RRset, or NULL if not present ldns_dnssec_name_print() Prints the RRs in the dnssec name structure to the given file descriptor out: the file descriptor to print to name: the name structure to print the contents of AUTHOR
The ldns team at NLnet Labs. Which consists out of Jelte Jansen and Miek Gieben. REPORTING BUGS
Please report bugs to ldns-team@nlnetlabs.nl or in our bugzilla at http://www.nlnetlabs.nl/bugs/index.html COPYRIGHT
Copyright (c) 2004 - 2006 NLnet Labs. Licensed under the BSD License. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. SEE ALSO
ldns_dnssec_zone. And perldoc Net::DNS, RFC1034, RFC1035, RFC4033, RFC4034 and RFC4035. REMARKS
This manpage was automaticly generated from the ldns source code by use of Doxygen and some perl. 30 May 2006 ldns(3)
All times are GMT -4. The time now is 07:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy