473,395 Members | 1,343 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,395 software developers and data experts.

system call in VC

Greetings all.

I am trying to make a system call as on WinXP,

#include <stdlib.h>

int main()
{
system( "ls -al");
}

but it is doing nothing!!

Has anybody ever experienced such a thing!? My belief is there is a
library that was missed when I installed VC but I am not sure.

Any suggestions, hints, pointers etc etc is greatly appreciated.

Cheers

Dec 16 '05 #1
10 2313
ka*****************@yahoo.ca said:
Greetings all.

I am trying to make a system call as on WinXP,

#include <stdlib.h>

int main()
{
system( "ls -al");
}

but it is doing nothing!!

Has anybody ever experienced such a thing!? My belief is there is a
library that was missed when I installed VC but I am not sure.

Any suggestions, hints, pointers etc etc is greatly appreciated.


Firstly, check that your system has an ls command that accepts the switch
-al. It is quite likely in your case that it does not, since ls isn't a
command normally associated with Windows systems.

Secondly, if your system does support an ls command, consider the
possibility that the system call is executing so quickly that you simply
don't see it. For example, consider doing something like:

system("ls -al > listing.txt");

and then checking for the existence of listing.txt.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Dec 16 '05 #2
ka*****************@yahoo.ca wrote:

Greetings all.

I am trying to make a system call as on WinXP,

#include <stdlib.h>

int main()
{
system( "ls -al");
}

but it is doing nothing!!

Has anybody ever experienced such a thing!? My belief is there is a
library that was missed when I installed VC but I am not sure.

Any suggestions, hints, pointers etc etc is greatly appreciated.


Try replacing "ls -al" with "dir -al"

--
pete
Dec 16 '05 #3
pete said:
Try replacing "ls -al" with "dir -al"


Are you *sure* dir takes -al? I'm not.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Dec 16 '05 #4
pete wrote:
ka*****************@yahoo.ca wrote:
#include <stdlib.h>

int main()
{
system( "ls -al");
}

but it is doing nothing!!

Has anybody ever experienced such a thing!? My belief is there is a
library that was missed when I installed VC but I am not sure.

Any suggestions, hints, pointers etc etc is greatly appreciated.

Try replacing "ls -al" with "dir -al"


Bad advice. The closest equivalent for "ls -al" is "dir /a".

--
Simon.
Dec 16 '05 #5
Richard Heathfield <in*****@invalid.invalid> writes:
pete said:
Try replacing "ls -al" with "dir -al"


Are you *sure* dir takes -al? I'm not.


It does if you have a file in the current directory named "-al".

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Dec 16 '05 #6
Check whether the program has rihgts to execute the command attribute
'-a'.

Try giving the absolute path.

Dec 16 '05 #7
ka*****************@yahoo.ca writes:
Greetings all.

I am trying to make a system call as on WinXP,

#include <stdlib.h>

int main()
{
system( "ls -al");
}

but it is doing nothing!!


system() is part of the C standard, but it's effect depends entirely
on the implementation, which means it's off topic here.

Anyway, the system() function returns a value. Save that value, and
read your implementation's documentation to find out what it means.

<OT>
Last time I checked 'ls' wasn't a valid dos/windows command, so
unless there is a file named ls.exe, ls.com, or ls.bat somewhere
I'd expect the system call to fail.
</OT>

/Niklas Norrthon
Dec 16 '05 #8
Keith Thompson wrote:

Richard Heathfield <in*****@invalid.invalid> writes:
pete said:
Try replacing "ls -al" with "dir -al"


Are you *sure* dir takes -al? I'm not.


It does if you have a file in the current directory named "-al".


That would have to be the case ;)

--
pete
Dec 16 '05 #9
"ab********@yahoo.co.in" <ab********@yahoo.co.in> writes:
Check whether the program has rihgts to execute the command attribute
'-a'.

Try giving the absolute path.


What program?

Please read <http://cfaj.freeshell.org/google/>.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Dec 16 '05 #10
ka*****************@yahoo.ca a écrit :
Greetings all.

I am trying to make a system call as on WinXP,

#include <stdlib.h>

int main()
{
system( "ls -al");
}

but it is doing nothing!!


I'm not surprised that the unix commands are not supported by the
Windows shell. Try this :

system( "dir");

also, you may need some pause to see the results :

system( "pause");

Note that this code is standard C (hence on-topic here), but is not
portable.

--
A+

Emmanuel Delahaye
Dec 16 '05 #11

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

Similar topics

1
by: Erik Johnson | last post by:
Hi, I am trying to spawn a daemon type program to go off on its own and do some work (asynchoronously) from within an HTTPServer, but I am running into a problem where the web browser (actually...
7
by: rahul8143 | last post by:
hello, what is difference between system call and library function call? Does library function call can have context switch to kernel mode? regards, rahul
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
7
by: RobKinney1 | last post by:
Hello, Wow...I have one for you all and hopefully I am not understanding this timer object correctly. I have a timer setup that pulses a connection through a socket every 60 seconds. But it...
6
by: leoman730 | last post by:
This is one of the interview question this morning, hope someone can help out with this. Thanks. What is the different between System call and library call?
21
by: omkar pangarkar | last post by:
Hi all, I have two simple hello world programs one using printf() and other using write() --prog 1-- #include<stdio.h> #include<stdlib.h> int main() { printf("Hello"); /* up to here...
1
by: sophia.agnes | last post by:
Dear all, I was going through peter van der linden's book expert C programming there i found the following:- Library call ------------ *call to a routine in a library *linked with user...
35
by: jleslie48 | last post by:
I've written a cgi program in C using the borland 5.5 free compiler, and it runs just fine on an Apache server. My only issue is if I issue some system calls the cgi suspends until the call...
2
by: Radz | last post by:
when the fork system call is executed, a new process is created. The original process is called the parent process whereas the new process is called the child process. The new process consists of a...
0
ashitpro
by: ashitpro | last post by:
Writing System Call Wrappers in User Space. Recently I saw a post in Linux/Unix section to know the user who deleted the file in linux. Currently there is nothing in linux which could achieve...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.