Sponsored Content
Special Forums UNIX Desktop Questions & Answers AIX how to read the file in function again and again Post 302897334 by aboy212u on Sunday 13th of April 2014 11:14:00 AM
Old 04-13-2014
AIX how to read the file in function again and again

dear friends

I have a wrote a shell script which works like this.
1.) a command is executed and the log is moved in the file.
2.) this file is copied in to the other file.
3.) used a grep command to find a particular word.
4.) if a particular word is there then the script will go to next step else it will sleep for 20 seconds.
5.) the source file which is now appended after sleep of 20 seconds will be copied the other file.
6.) the updated other file is read a particluar word is searched again.

the script is as shown below.

Code:
searchstring()
{
if [ `echo $req1 | grep -c "SUCCESS" ` -gt 0 ]
then
  echo "Sleep 10"
else
  echo "sleep 50"
  sleep 50
  cp dellog.txt dellog02.txt
  searchstring
fi
}
cp dellog.txt dellog02.txt
req1=`grep SUCCESS dellog02.txt`
#echo $req1
searchstring

now after executing this sheel script the copied file is showing the word that i want but it is executing else part and the same step is getting repeated.

i hope you people will help me.

---------- Post updated at 10:14 AM ---------- Previous update was at 09:49 AM ----------

dear friends

i got the answer. i missed line req1=`grep SUCCESS dellog02.txt` after copy in function.

thank you

ravi

Last edited by Scrutinizer; 04-13-2014 at 11:56 AM.. Reason: code tags
 

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
SLEEP(3)								 1								  SLEEP(3)

sleep - Delay execution

SYNOPSIS
int sleep (int $seconds) DESCRIPTION
Delays the program execution for the given number of $seconds. PARAMETERS
o $seconds - Halt time in seconds. RETURN VALUES
Returns zero on success, or FALSE on error. If the call was interrupted by a signal, sleep(3) returns a non-zero value. On Windows, this value will always be 192 (the value of the WAIT_IO_COMPLETION constant within the Windows API). On other platforms, the return value will be the number of seconds left to sleep. ERRORS
/EXCEPTIONS If the specified number of $seconds is negative, this function will generate a E_WARNING. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.4 | | | | | | | Before PHP 5.3.4, on Windows, sleep(3) always | | | returns NULL when sleep has occurred, regardless | | | of whether the sleep was interrupted or not. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 sleep(3) example <?php // current time echo date('h:i:s') . " "; // sleep for 10 seconds sleep(10); // wake up ! echo date('h:i:s') . " "; ?> This example will output (after 10 seconds) 05:31:23 05:31:33 SEE ALSO
usleep(3), time_nanosleep(3), time_sleep_until(3), set_time_limit(3). PHP Documentation Group SLEEP(3)
All times are GMT -4. The time now is 02:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy