473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to store output into variable in perl

Hi,

Output of "ps -o etime,time,pcpu,pmem,fname -C sbd-java"
command is -
Elapsed Time %cpu %MEM COMMAND
02:14:03 00:03:28 2.5 6.3 sbd-java

In shell script-(when i run below code)
X=`ps -o etime,time,pcpu,pmem,fname -C sbd-java --no-heading|awk '{print $3 }'`;

echo $X

output-2.5

i want use same application in perl script.
Is their any change required in above code.i have tried usind the same code in perl but its not working...)

can you plz tell me what changes need to be do??
Apr 7 '11 #1
1 2119
miller
1,089 Expert 1GB
Just use backticks

Expand|Select|Wrap|Line Numbers
  1. my $results = `ps -o etime,time,pcpu,pmem,fname -C sbd-java`;
  2.  
Apr 7 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: JC | last post by:
Can someone post a working stored procedure with output variable that works on northwind db or explain to me what I am missing. I've tried ever tying but it always returns @outvariable parameter...
6
by: Jan Olsen | last post by:
Used a regular "select query". Wanted to store the output, but can't find any way of storing the output data to a new table. I had to spend ages running the query once again, first selecting "make...
12
by: harishg2 | last post by:
Hi, How to store a variable value for more than one executions. Ex: main() { int i=0; i++; printf("%d",i);
2
by: Abdul Qadir Khan | last post by:
Hi All, Is it possible to call a function whose name is store in variable using VB.Net. Assume this dim a as string a = "GetEmployee()" Now I have function name in a variable, how can I...
1
by: Joey Liang via DotNetMonster.com | last post by:
Hi all, Is it possible to store double variable to session? If possible can show me code sample on how to convert.Thanx n advance. -- Message posted via http://www.dotnetmonster.com
0
by: mfilpot | last post by:
I am working on a prime number generator for sschool, but I jsut can't seem to figure out how to write the contents of the variable MeSSage into a new text file, Can someone help me? the script...
4
by: wish | last post by:
Hi all, Where is the location for store session variable? Because i feel that the session variable is keep store the previous variable and no release the variable. When i click back button,...
1
by: santhanalakshmi | last post by:
Hi, When i run the program in web server, getting the only output Content-type: text/html . Not displaying anything else. I don't know, whats a problem ? Please check my code. ...
1
by: arvind nikam | last post by:
I am writing a 'C' program to implement advanced shell which will allow me pipes and redirection so please tell me how can I store the out of system calls to a file or variable.
3
by: Kumar Rounak | last post by:
i have an exe which do some processing on my device. i want to write a perl script which calls this exe and runs it in background collects its out in file and process that file in perl program. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.