473,396 Members | 2,129 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,396 software developers and data experts.

How to hide "system()" output?

Hallo,

I want to see from php-file list of files which are in directory, where
is the given php-file. To do so, I put in the php-file the following
line:

<?php $sys = system("ls") ?>

Then I would like to work with string $sys. However, in the place where
the "system()" is executed, php-file print on screen result of the
execution. I would like to avoid this. Do you know how I can do it?

Jul 17 '05 #1
2 3714
NC
opt_inf_...@yahoo.com wrote:

I want to see from php-file list of files which are in directory,
where is the given php-file. To do so, I put in the php-file the
following line:

<?php $sys = system("ls") ?>

Then I would like to work with string $sys. However, in the place
where the "system()" is executed, php-file print on screen result
of the execution. I would like to avoid this. Do you know how I
can do it?


$sys = `ls`;

Note that the command is enclosed in backticks (`), not single
quotes (').

Also, you may want to avoid program execution calls, because
they may not be available on your hosting service. Consider
using opendir()/readdir() instead:

http://www.php.net/opendir

Cheers,
NC

Jul 17 '05 #2
On 6 Apr 2005 13:36:15 -0700, op*********@yahoo.com wrote:
I want to see from php-file list of files which are in directory, where
is the given php-file. To do so, I put in the php-file the following
line:

<?php $sys = system("ls") ?>

Then I would like to work with string $sys. However, in the place where
the "system()" is executed, php-file print on screen result of the
execution. I would like to avoid this. Do you know how I can do it?


In this case, use opendir() and readdir() instead.

Or to answer the specific question, read the manual for system(), which points
to the related function exec(). But don't use that.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jerry Sievers | last post by:
Hello. Maybe I'm just out of practice, maybe not. Suppose we run a command using system() and this command writes to the stderr stream. If I remember correctly, this is normally written to the...
9
by: /* frank */ | last post by:
I want system ("CLS") if the system is WINDOWS system ("CLEAR") is the OS is a UNIX like.
11
by: T O | last post by:
Hi all, I am very new to C programming and have come across problem. My programme has opened and created a text document on the hard drive. The document name is stored in a string called...
11
by: Paminu | last post by:
Is there something like system("PAUSE") for linux?
5
by: msigwald | last post by:
I'm trying to write a little C program to run under linux, which must gain root so it can then shutdown the computer. I can get the code to execute the su command via system("su"), but once su...
21
by: Neel | last post by:
I am trying to "ping" a remote host in my C++/Redhat Linux code to check whether that host is connected or not. if (0 == system("ping -w 2 192.168.0.2)) But, in both cases...
3
by: Acrobatic | last post by:
Hello I've got a simple Perl script that works fine from the command line but not from PHP via the browser. It's a conversion program that converts an image to a different format, and writes the...
2
by: =?Utf-8?B?cmVk?= | last post by:
Hi Friends, We recently deployed our application to production and I am experiencing the below error message. Cannot access a disposed object named "System.Net.TlsStream" The error occurs...
4
by: sebastien.willemijns | last post by:
hello, i use a small PHP script to grab DNS infos at http://80.247.230.136/bug/php/ (php and txt available) the trouble is the last line of every output given by "system" function is always...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.