Sponsored Content
Top Forums Shell Programming and Scripting Avoid file creation in a script...achive same result Post 302350634 by ak835 on Friday 4th of September 2009 11:12:15 AM
Old 09-04-2009
MySQL Avoid file creation in a script...achive same result

Guys
following lines help me in getting numbers from PID column ,to be thrown into first column of a CSV file.


Code:
COLUMNS=2047 /usr/bin/ps -eo pid,ppid,uid,user,args | grep -v "PID" > /tmp/masterPID.txt
cat /tmp/masterPID.txt|while read line
do
PID=`echo $line|awk '{print $1}'`
echo "$PID"
done

Using following lines,i am able to print PPID column ,corrsponding to PID found above. [ Do not bother about "@@Host Processes.PID@@".My tool allows me to pass variables from column to column ]

Code:
PID="@@Host Processes.PID@@"
cat /tmp/masterPID.txt|while read line
do
temp=`echo $line|awk '{print $1}'`
if [ $temp = $PID ]
then
PPID=`echo $line|awk '{print $2}'`
echo "$PPID"
fi
done

My problem is ,even though i am able to get both columns in my CSV file,this code is doing a lot of I/O because of static file creation on box.I am myself against using a static file.

Is there a way i can achive the same without creating any file?

Regards
Abhi
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creation and Transfer of TAR file from one machine to another Using UNIX script

Hi, I want to create unix script such that it should run on machine A, it should run TAR commands on machine B and copy that TAR to machine C. Is it possible? Thanks Rahul (2 Replies)
Discussion started by: rahuljadhav
2 Replies

2. Shell Programming and Scripting

Creation of script,if the data file have more than one entry!!!

1.Daily there will be 14 files in the data directory 2.someday's the 14 files receive more than once r twice with different time stamps....we need to chk the count of the file and if the count of the file is two.we need to combine the both the files. 3. if any duplicate data is there just... (1 Reply)
Discussion started by: bobprabhu
1 Replies

3. Shell Programming and Scripting

shell script result to file

Since I'm not an expert in shell scripting, I have question on sending script result to file. I have script like this... if condition=0: then echo "service is not running" | mail -s "Server Status" uname@companyname fi sleep 10 if configtion=1: then echo "service is not running" | mail -s... (3 Replies)
Discussion started by: s_linux
3 Replies

4. Shell Programming and Scripting

Script not spooling in result file

Hi everyone and nice to meet you :) I'm having some issues with a script I'm writing. It's probably most chaotic, I'm no ksh guru, but the idea is to extract an ID with that query, spool it into a file, and read that file making the ID a variable. This has to be done for every row extracted by... (10 Replies)
Discussion started by: Arkadia
10 Replies

5. Shell Programming and Scripting

Script to write result to a file

Hello, How can I run this script every 1 hour and save its result to result.txt ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' Regards Shaan (5 Replies)
Discussion started by: Shaan_Shaan
5 Replies

6. Shell Programming and Scripting

File system creation script on AIX 6.1 using while loop

#!/bin/sh echo "VG: " read VG echo "LP: " read LP echo "SAP: " read SAP echo "NUM: " read NUM echo "SID: " read SID while ]; read VG LP SAP NUM SID ; do mklv -y $SAP$NUM -t jfs2 -e x $VG $LP; crfs -v jfs2 -d /dev/$SAP$NUM -m /oracle/$SID/$SAP$NUM ... (14 Replies)
Discussion started by: arorap
14 Replies

7. Shell Programming and Scripting

List creation - Grep a line in a file with a script name

Hi, I have a list file which has script names in them. Some scripts take lists as parameters which inturn have script names. This is basically for sequencing the job run. Eg: List1: test1.ksh test2.ksh test2.lst test3.ksh test3.lst test4.ksh test2.lst: test21.ksh test23.ksh... (7 Replies)
Discussion started by: member2014
7 Replies

8. Shell Programming and Scripting

CSV File Creation Within Shell Script

Hi All, I am trying to create a CSV file within a shell script test.ksh and the code snippet is something like below: #!/usr/bin/ksh # Set required variables. . $HOME/.prof # Output file path Group1=/tmp/G1.csv Group2=/tmp/G2.csv Group3=/tmp/G3.csv $ORACLE_HOME/bin/sqlplus -s... (2 Replies)
Discussion started by: swasid
2 Replies

9. Shell Programming and Scripting

Script to print file name and its creation date

Hello , I am looking for a script to print file name and its last updated time. FILE CREATION-TIME FILE-NAME 24/10/2017 12:34 TDR-IU-8-2017.10.24.07:40:00-2017.10.24.07:45:00 when we run l command it print the directory and the files with details like permission,... (1 Reply)
Discussion started by: sadique.manzar
1 Replies

10. UNIX for Beginners Questions & Answers

Need UNIX script to check checksum and dummy file creation.

Hi Folks, I need a UNIX script which will copy files(Table wise) from source directory to destination directory (Under table directory) and also creates 2 additional files after getting copied to destination directory with extension .pdy and .ldy , . pdy file will be zero byte file should get... (4 Replies)
Discussion started by: Nicks1412
4 Replies
FBSQL_FETCH_FIELD(3)							 1						      FBSQL_FETCH_FIELD(3)

fbsql_fetch_field - Get column information from a result and return as an object

SYNOPSIS
object fbsql_fetch_field (resource $result, [int $field_offset]) DESCRIPTION
Used in order to obtain information about fields in a certain query result. PARAMETERS
o $ result -A result identifier returned by fbsql_query(3) or fbsql_db_query(3). o $field_offset - The numerical offset of the field. The field index starts at 0. If not specified, the next field that wasn't yet retrieved by fbsql_fetch_field(3) is retrieved. RETURN VALUES
Returns an object containing field information, or FALSE on errors. The properties of the object are: o name - column name o table - name of the table the column belongs to o max_length - maximum length of the column o not_null - 1 if the column cannot be NULL o type - the type of the column EXAMPLES
Example #1 fbsql_fetch_field(3) example <?php fbsql_connect($host, $user, $password) or die("Could not connect"); $result = fbsql_db_query("database", "select * from table") or die("Query failed"); # get column metadata $i = 0; while ($i < fbsql_num_fields($result)) { echo "Information for column $i:<br /> "; $meta = fbsql_fetch_field($result); if (!$meta) { echo "No information available<br /> "; } echo "<pre> max_length: $meta->max_length name: $meta->name not_null: $meta->not_null table: $meta->table type: $meta->type </pre>"; $i++; } fbsql_free_result($result); ?> SEE ALSO
fbsql_field_seek(3). PHP Documentation Group FBSQL_FETCH_FIELD(3)
All times are GMT -4. The time now is 10:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy