Sponsored Content
Full Discussion: File Validation
Top Forums UNIX for Dummies Questions & Answers File Validation Post 302345616 by scripter.online on Wednesday 19th of August 2009 05:20:31 PM
Old 08-19-2009
Hi Kumar,

Code:
 

$cat > filevalidate.sh
#!/bin/ksh
 
FILENAME=${1}
FILECOUNT=`cat ${FILENAME} | wc -l`
COUNT=`expr ${FILECOUNT} - 2`
if [ `head -1 ${FILENAME} | cut -c 1` = H ]
then
        if [ `tail -1 ${FILENAME} | cut -c 1` = T ] && [ ${COUNT} -eq `tail -1 ${FILENAME} | cut -d ":" -f2`  ]
        then
                echo "Valid file"
        else
                echo "Invalid file(T)"
        fi
else
        echo "Invalid file(H)"
fi

$./filevalidate.sh testfile


Last edited by scripter.online; 08-19-2009 at 06:30 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

validation :file <filename>

My user is ftp a CSV file from window. There is possiblity to doing FTP through different mode. This file is then picked by another program, but I want to make sure the FTP file would be always ascii format, bu releasing a commaon File <file name> Can any one provide input , abut how to put a... (2 Replies)
Discussion started by: u263066
2 Replies

2. Shell Programming and Scripting

File name and format validation

Hi Gurus, I used unix long time back. I need help for writing a unix script which can be automated and execute every day on specific time. 1.) This is the actual functional requirement. Informatica should reject incoming files that have invalid filenames or file formats 2.) My File... (6 Replies)
Discussion started by: vsmeruga
6 Replies

3. UNIX for Dummies Questions & Answers

file name with timestamp validation

Hi , I am trying to write a shell script which will validate all .csv file names in a directory , my file name format is as below. CDR_SCAN_Report_YYYYMMDDHHMI.csv 1. I need to validate the name should start with CDR_SCAN_Report. 2. And the time stamp part is a valid time stamp,if it is... (1 Reply)
Discussion started by: shruthidwh
1 Replies

4. Shell Programming and Scripting

File Name Validation

Hi All, I am trying to validate the file name against the naming convention mentioned in configuration file. In the configuration file, the file name convention is mentioned as: Myfile_SQ<NN>_<NN>_YYYYMMDD_HHMMSS.xml The actual file received is Myfile_SQ10_30_20110423_073002.xml How do... (1 Reply)
Discussion started by: angshuman
1 Replies

5. Shell Programming and Scripting

Input validation of file

Hi, I'm trying to do input validation for a file. If the user fails to enter a file name, the script should prompt for the file name or exit. I'm using this script to integrate with a bigger script which does ftp of the files which are "read". #!/bin/ksh echo "enter a file name" if then... (16 Replies)
Discussion started by: sam_bd
16 Replies

6. Shell Programming and Scripting

File validation

Hello, File contains 1,3 and 5 are required columns. it's working use this command. awk -F\| '$1 && $3 && $5' test1.txt > test2.txt How can use this unix programming.while using runnign this scirpt,it's raising the error. awk: ^ syntax error #!/usr/bin/ksh `awk -F\| '$1 &&... (3 Replies)
Discussion started by: bammidi
3 Replies

7. Shell Programming and Scripting

XML file validation

Hi, i am new to unix script. i have two xml files. one is orderinfo.xml and another one is xsd file(EmailMessage.xml). we need to compare the both file for poper nodes exists are not. for example: <xsd:element name="EmailMessage"> tag in the EmailMessage.xml file(xsd sheet),this tag... (2 Replies)
Discussion started by: bmk
2 Replies

8. Shell Programming and Scripting

Unicode file validation

I don't want HTML_CONTENT,RICH_CONTENT,TEXT_CONTENT columns data in the file and reset of data we need to extract. Find the attached file. Need to extract date in between DI_UX_ROW_END tag. Can help me using unix command using AWK. Thanks, (2 Replies)
Discussion started by: bmk
2 Replies

9. Shell Programming and Scripting

File validation

Hi there, As a part of file validation, I needed to check for delimiter count in the file. My aim is to find, how many records have failed to have predefined numbers of delimiters in the file. My code looks like below i=`awk -F '|' 'NF != 2 {print NR, $0} ' ${pinb_fldr}/${pfile}DAT |... (3 Replies)
Discussion started by: anandapani
3 Replies

10. UNIX for Dummies Questions & Answers

Validation before moving the File

Hi, Before moving the files from source directory to target directory I need to check if the files have these strings 'Error', 'Not Valid' ,' YTF-' or if the file is a zero byte file, if the file contains these strings or if it is a zero byte file i should log a entry in the log file and fail... (5 Replies)
Discussion started by: gaur.deepti
5 Replies
HOBBITLAUNCH(8) 					      System Manager's Manual						   HOBBITLAUNCH(8)

NAME
hobbitlaunch - Master program to launch other Xymon programs SYNOPSIS
hobbitlaunch [options] DESCRIPTION
hobbitlaunch(8) is the main program that controls the execution and scheduling of all of the components in the Xymon system. hobbitlaunch allows the administrator to add, remove or change the set of Xymon applications and extensions without restarting Xymon - hob- bitlaunch will automatically notice any changes in the set of tasks, and change the scheduling of activities accordingly. hobbitlaunch also allows the administrator to setup specific logfiles for each component of the Xymon system, instead of getting output from all components logged to a single file. OPTIONS
--env=FILENAME Loads the environment from FILENAME before starting other tools. The environment defined by FILENAME is the default, it can be overridden by the ENVFILE option in hobbitlaunch.cfg(5) --config=FILENAME This option defines the file that hobbitlaunch scans for tasks it must launch. A description of this file is in hobbitlaunch.cfg(5) The default tasklist is /etc/hobbitlaunch.cfg --log=FILENAME Defines the logfile where hobbitlaunch logs information about failures to launch tasks and other data about the operation of hobbit- launch. Logs from individual tasks are defined in the hobbitlaunch.cfg file. By default this is logged to stdout. --pidfile=FILENAME Filename which hobbitlaunch saves its own process-ID to. Commonly used by automated start/stop scripts. --verbose Logs the launch of all tasks to the logfile. Note that the logfile may become quite large if you enable this. --dump Just dump the contents of the hobbitlaunch.cfg file after parsing it. Used for debugging. --debug Enable debugging output while running. --no-daemon hobbitlaunch normally detaches from the controlling tty and runs as a background task. This option keeps it running in the fore- ground. STARTING TASKS
hobbitlaunch will read the configuration file and start all of the tasks listed there. If a task completes abnormally (i.e. terminated by a signal or with a non-zero exit status), then hobbitlaunch will attempt to restart it 5 times. If it still will not run, then the task is disabled for 10 minutes. This will be logged to the hobbitlaunch logfile. If the configuration file changes, hobbitlaunch will re-read it and notice any changes. If a running task was removed from the configura- tion, then the task is stopped. If a new task was added, it will be started. If the command used for a task changed, or it was given a new environment definition file, or the logfile was changed, then the task is stopped and restarted with the new definition. SEE ALSO
hobbitlaunch.cfg(5), xymon(7) Xymon Version 4.2.3: 4 Feb 2009 HOBBITLAUNCH(8)
All times are GMT -4. The time now is 02:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy