Sponsored Content
Special Forums UNIX Desktop Questions & Answers AIX how to read the file in function again and again Post 302897882 by wisecracker on Wednesday 16th of April 2014 02:36:51 PM
Old 04-16-2014
You marked this thread as [SOLVED] using the title colour change.

Here is a idea that is totally untested so be aware of that.

Do NOT discard your current incarnation until this is proven...
Code:
# Shebang line here...
# Loop something like this...
# <Some unknown setup code here>
# IMPORTANT:- UNABLE TO TEST.
#
cp dellog.txt dellog02.txt
# req1=`grep SUCCESS dellog02.txt`
req1=$(grep SUCCESS dellog02.txt)
#
while true
do
	# This section is added to exit the loop cleanly and manually...
	char=""
	# This line will sleep for 10 seconds UNLESS a key is pressed...
	read -n1 -s -t10 char
	# Q or q will exit/quit/breakout depending upon your requirement...
	if [ "$char" == "Q" ] || [ "$char" == "q" ]
	then
		break
		# exit # <some_return_code>
	fi
	# End of loop exit code...
	# if [ `echo $req1 | grep -c "SUCCESS" ` -gt 0 ]
	if [ $(echo $req1 | grep -c "SUCCESS") -gt 0 ]
	then
		# req1=`grep SUCCESS dellog02.txt`
		req1=$(grep SUCCESS dellog02.txt)
		echo "$req1"
		# sleep 10
	else
		echo "Copying file(s)..."
		cp dellog.txt dellog02.txt
		# sleep 50
		sleep 40
	fi
done
#
echo "You have exited the continuous loop..."


Last edited by wisecracker; 04-20-2014 at 03:43 PM.. Reason: Correct a typo in the if statement line...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

read function

Hello all In UNIX i wrote a program which simply establishes a conncetion with another system, using write system call i wrote a message to the server from client and from the server i send another message, for the second time i send a mesage using write system call to the server, when i send a... (1 Reply)
Discussion started by: rajashekaran
1 Replies

2. Programming

read a file wich fscanf() in a function

I use fopen, fscanf, fclose to read a file. It can work well. since many files should be read, a function is created with the same code. But in the function, fscanf can not work well. for example, the first line of the the file is: > filename but the fscanf will give: 207/23/eee/34 it appears... (2 Replies)
Discussion started by: cdbug
2 Replies

3. Programming

Cannot read a file with read(fd, buffer, buffersize) function

# include <stdio.h> # include <fcntl.h> # include <stdlib.h> # include <sys/stat.h> int main(int argc, char *argv) { int fRead, fPadded, padVal; int btRead; int BUFFSIZE = 512; char buff; if (argc != 4) { printf ("Please provide all of the... (3 Replies)
Discussion started by: naranja18she
3 Replies

4. Shell Programming and Scripting

AIX file read for file name script

Hi al, Im trying to write something to read a date file and append each date to my file output name. Datefile: 20091001 20091015 Final output file I would like is: DATA_20091001_20091015.xls The script Im trying, but not working, is n=`wc -l < dates_yymmdd.txt` i=1 (2 Replies)
Discussion started by: NycUnxer
2 Replies

5. UNIX for Advanced & Expert Users

How UNIX/AIX handles a file deep down, say it's being read while another one tries to rename it?

Hi Thinkers, On AIX 5.3, we have a monitor program that reads the log file and searching for a certain string pattern that we define(say "transactionException"), if it sees it then it will raise an alert by sending an email. Because the log file XXX.log is rolling into XXX.log.0, XXX.log.1,... (2 Replies)
Discussion started by: TheGunMan
2 Replies

6. Shell Programming and Scripting

Read Table,View,Package,Function and Procedure Name in a File

Hi I am new to Unix shell scripting. But i need help to slove the below issue. Issue description: I want to read table, view names and package names in a file my plan to find the table name is : search "From" key word find the table or view To find the packge name : Search "Package... (5 Replies)
Discussion started by: sboss
5 Replies

7. AIX

Not able to read redo log file on AIX box

I have a oracle 10 G database installed on AIX6.1) server. The database user creates online redo log files with permissions 640 i.e. read access to group oinstall I am not able to read the files with another user part of the group oinstall. even tried to copy the files to another location,... (5 Replies)
Discussion started by: amitnm1106
5 Replies

8. Homework & Coursework Questions

C++ Attempting to modify this function to read from a (;) semi-colon-separated file

After some thought. I am uncomfortable issuing my professors name where, there may be unintended side effects from any negative responses/feedback. Willing to re post if I can omit school / professor publicly, but can message moderator for validation? I am here for knowledge and understanding,... (1 Reply)
Discussion started by: briandanielz
1 Replies

9. Shell Programming and Scripting

[Bash] Read History function & Read Arrowkeys

Hi. How can I create a history function? (By "read" command or so) & How can I configure a read command so that the arrow keys are not displayed so funny? (^[[A) Thanks in advance. (4 Replies)
Discussion started by: sinnlosername
4 Replies

10. Shell Programming and Scripting

Read file input in while loop does not work on AIX system

I'm working on Aix 6.1 and using ksh shell. The below works fine on Linux bash or ksh shell . while IFS= read -r dirpath ; do echo "Hi" done <<<"$var" However, any such while loop that reads the input from file or variable using <<< fails on Aix system with the below error: Below... (2 Replies)
Discussion started by: mohtashims
2 Replies
ZGREP(1)						      General Commands Manual							  ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 06:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy