Sponsored Content
Full Discussion: Problem with grep on aix
Top Forums Shell Programming and Scripting Problem with grep on aix Post 302594273 by knight_eon on Tuesday 31st of January 2012 02:00:24 AM
Old 01-31-2012
Quote:
Originally Posted by sukhdip
Hi..
I am facing a strange problem on AIX with ksh scripting.
The problem is with grep command. It's not able to work in the below code.

Code:
#!/bin/ksh
 
run_count=1
catalog_name="rrc"
cd /Dataload_Scripts/Files/$catalog_name
#file=""
for file in $run_count"_"*.csv; do
 echo $file
 
 # Getting row count from property file
 FILE_NAME=$run_count"_"$catalog_name"_Record_Count.txt"
 echo "FILE_NAME " $FILE_NAME
 PROP_KEY=$file
 echo "PROP_KEY" $PROP_KEY
 RowCount_from_prop=$(cat ${FILE_NAME} | grep "${PROP_KEY}" | cut -d'=' -f2 | tr -d '\r')
 echo "RowCount_from_prop" $RowCount_from_prop
 
 # Get row count from csv file
 RowCount_from_csv=$(awk 'END { print NR-1 }' $file)
 echo "RowCount_from_csv= "$RowCount_from_csv
 
 if [ "$RowCount_from_csv" == "$RowCount_from_prop" ]
 then
  echo "column header count row proper"
 else
  echo "column header count not correct in " $file
  ret_flag=1
 fi
done
if [ $ret_flag -eq 1 ]; then
 echo "exiting with errors"
 exit 1
else
 exit 0
fi

I'm not able to get value in RowCount_from_prop. echo is showing only blanks Image upto cat command its working fine. but at grep dunno whats happening.
Code:
1_rrc_attribute.csv
FILE_NAME  1_rrc_Record_Count.txt
PROP_KEY 1_rrc_attribute.csv
RowCount_from_prop
RowCount_from_csv= 203
column header count not correct in  1_rrc_attribute.csv


The way I look at your script, to me it seems that FILE_NAME 1_rrc_Record_Count.txt should contain 1_rrc_attribute.csv as data...

But just for the sake of making life easier, can we actually see the content of the file 1_rrc_Record_Count.txt and 1_rrc_attribute.csv ...
 

10 More Discussions You Might Find Interesting

1. AIX

AIX pg problem

Hi all, I have problem with regards to using pg on AIX v5.3.0.0 . Here wht i am trying to do --- i have shell script with the following statements if || then echo ^[[?3h tput clear pg -f $1$2 echo ^[[?3l ... (0 Replies)
Discussion started by: ramanujapuram
0 Replies

2. UNIX for Advanced & Expert Users

AIX 5.2 problem

Hello, I'm working on a AIX5.2 OS. The problem i'm facing is that the system performance is good in rrot login, but when i switch to other users login it is very slow. A ls or even pwd command take almost 20 to 30 sec to disply output. The same logins are working fine on other... (2 Replies)
Discussion started by: pradeepmacha
2 Replies

3. AIX

AIX 4.2 Korn shell and grep question

Ho do I find out the verion of the Kron shell on my client`s system ? There is no one to ask. They are not knowledged enough (hard to believe but yes). Also, on that AIX 4.2, I am trying to figure out how to do a grep using a search patter like below but does not seam to work. The '*' do... (11 Replies)
Discussion started by: Browser_ice
11 Replies

4. AIX

AIX OS problem? network problem?

Dear ALL. I installed AIX OS on customer sites. but Only one site is too slow when I connected telnet, ftp.. Ping is too fast. but telnet and FTP is not connected.. of course i check the configuration file on aix but it's normal. Do any Idea?? thanks in advance. - Jun - (3 Replies)
Discussion started by: Jeon Jun Seok
3 Replies

5. AIX

Grep last 5 mins from log file in AIX

I want to grep only last 5 mins of a log file in bash I have a syslog which contains the following Mon Jul 11 20:47:42 Mon Jul 11 20:47:52 The following works in Unix but not in AIX . Please can you let me know as to what would be the AIX equivalent Code: for (( i = 5; i >=0;... (1 Reply)
Discussion started by: necro98
1 Replies

6. Shell Programming and Scripting

aix :grep to get lines before and after string

am using AIX and I have a string "There is no process to read data written to a pipe". I want to get the output 2 lines before and 4 lines after this string. The string is present like more than 100 times in the log and I want to output, the last result in the log with this string I tried using... (1 Reply)
Discussion started by: PhAnT0M
1 Replies

7. AIX

AIX 6.1 reach the threshold of stream(no -a|grep strthresh)

last night i want to do oracle full backup with expdp when i switch to oracle it hangs,it looks like: su - oracle there is nothing feedback and hang ,but su - root work fine. then i use truss su - oracle found it stuck at "ENOSR" ,then i changed the kernel parameter of strthresh from 85 to 90... (7 Replies)
Discussion started by: machinen
7 Replies

8. AIX

How to grep PID and program name from netstat in AIX?

Hi All, I am using netstat on AIX to grep info on all open connections. However, unlike on Linux(Centos), I do not get the PID and program name using netstat on AIX. I need this info to be clubbed along with the information retrieved using netstat version of AIX. Is there a way this can be... (1 Reply)
Discussion started by: Vipin Batra
1 Replies

9. UNIX for Dummies Questions & Answers

sed Or Grep Problem OR Terminal Problem?

I don't know if you guys get this problem sometimes at Terminal but I had been having this problem since yesterday :( Maybe I overdid the Terminal. Even the codes that used to work doesn't work anymore. Here is what 's happening: * I wanted to remove lines containing digits so I used this... (25 Replies)
Discussion started by: Nexeu
25 Replies

10. AIX

Need grep -v Equivalent for AIX

Need grep -v "Hello" equivalent for AIX (9 Replies)
Discussion started by: mohtashims
9 Replies
MSSQL_FETCH_FIELD(3)													      MSSQL_FETCH_FIELD(3)

mssql_fetch_field - Get field information

SYNOPSIS
object mssql_fetch_field (resource $result, [int $field_offset = -1]) DESCRIPTION
mssql_fetch_field(3) can be used in order to obtain information about fields in a certain query result. PARAMETERS
o $result - The result resource that is being evaluated. This result comes from a call to mssql_query(3). o $field_offset - The numerical field offset. If the field offset is not specified, the next field that was not yet retrieved by this function is retrieved. The $field_offset starts at 0. RETURN VALUES
Returns an object containing field information. The properties of the object are: o name - column name. if the column is a result of a function, this property is set to computed#N, where #N is a serial number. o column_source - the table from which the column was taken o max_length - maximum length of the column o numeric - 1 if the column is numeric o type - the column type. EXAMPLES
Example #1 mssql_fetch_field(3) example <?php // Connect to MSSQL and select the database mssql_connect('MANGOSQLEXPRESS', 'sa', 'phpfi'); mssql_select_db('php'); // Send a select query to MSSQL $query = mssql_query('SELECT * FROM [php].[dbo].[persons]'); // Construct table echo '<h3>Table structure for 'persons'</h3>'; echo '<table border="1">'; // Table header echo '<thead>'; echo '<tr>'; echo '<td>Field name</td>'; echo '<td>Data type</td>'; echo '<td>Max length</td>'; echo '</tr>'; echo '</thead>'; // Dump all fields echo '<tbody>'; for ($i = 0; $i < mssql_num_fields($query); ++$i) { // Fetch the field information $field = mssql_fetch_field($query, $i); // Print the row echo '<tr>'; echo '<td>' . $field->name . '</td>'; echo '<td>' . strtoupper($field->type) . '</td>'; echo '<td>' . $field->max_length . '</td>'; echo '</tr>'; } echo '</tbody>'; echo '</table>'; // Free the query result mssql_free_result($query); ?> SEE ALSO
mssql_field_seek(3). PHP Documentation Group MSSQL_FETCH_FIELD(3)
All times are GMT -4. The time now is 03:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy