473,809 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

system question

I'm writing a little c program and one of things I'm trying to get it to do
is cd to a particular directory and then run an exe that is on my path, as
follows...

strcpy(working_ string, "c:\\davedata\\ bats\\ks.exe fnord");
system("cd \\playtime\\d\\ build\\html");
system(working_ string);

But ks.exe does not seem to be invoked on the files in the
\\playtime\\d\\ build\\html directory.

Can someone tell me how to do this?
Nov 14 '05 #1
3 1390
David Schwartz <da*******@hotm ail.com> wrote:
I'm writing a little c program and one of things I'm trying to get it to do
is cd to a particular directory and then run an exe that is on my path, as
follows... strcpy(working_ string, "c:\\davedata\\ bats\\ks.exe fnord");
system("cd \\playtime\\d\\ build\\html");
system(working_ string); But ks.exe does not seem to be invoked on the files in the
\\playtime\\d\\ build\\html directory. Can someone tell me how to do this?


The first invocation of system() creates a shell in which you do the 'cd'.
Then the shell exits. As the next step you invoke a completely new shell
by calling system() again that has no idea about the working directory of
the other shell that's already dead. Execute both commands in the _same_
call of system().
Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@p hysik.fu-berlin.de
\______________ ____________ http://www.toerring.de
Nov 14 '05 #2
In <c5************ @uni-berlin.de> Je***********@p hysik.fu-berlin.de writes:
David Schwartz <da*******@hotm ail.com> wrote:
I'm writing a little c program and one of things I'm trying to get it to do
is cd to a particular directory and then run an exe that is on my path, as
follows...

strcpy(working_ string, "c:\\davedata\\ bats\\ks.exe fnord");
system("cd \\playtime\\d\\ build\\html");
system(working_ string);

But ks.exe does not seem to be invoked on the files in the
\\playtime\\d\\ build\\html directory.

Can someone tell me how to do this?


The first invocation of system() creates a shell in which you do the 'cd'.
Then the shell exits. As the next step you invoke a completely new shell
by calling system() again that has no idea about the working directory of
the other shell that's already dead. Execute both commands in the _same_
call of system().


And if your shell doesn't allow this directly, build a script
containing the two commands and execute that script with system().

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #3
David Schwartz wrote:

I'm writing a little c program and one of things I'm trying to
get it to do is cd to a particular directory and then run an exe
that is on my path, as follows...

strcpy(working_ string, "c:\\davedata\\ bats\\ks.exe fnord");
system("cd \\playtime\\d\\ build\\html");
system(working_ string);

But ks.exe does not seem to be invoked on the files in the
\\playtime\\d\\ build\\html directory.

Can someone tell me how to do this?


Not here. The C language has neither directories nor exes nor
paths. You want a group dealing with your peculiar system, which
I suspect to be either Windows or MsDos.

--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!

Nov 14 '05 #4

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

Similar topics

5
12051
by: Abraham Lopez | last post by:
Hi.. Is there a way to convert a System.Array to XML... If you know thanks very much... if you don't... Please do not respond stupid things like " Yes -- many ways."
7
7543
by: MLH | last post by:
Where is system.mdw normally stored in typical A97 installation?
20
13139
by: SR | last post by:
Hi, I need to read the output from a system( ) function within a C program. The function however only returns the exit status. How can I read what system( ) sends to stdout ? (is there a simpler way than having to fork a child process and then catching its output ?) (if needed: working on linux) Thanks
4
7190
by: The Spoon | last post by:
I am looking for functions that can be used to automatically update the system date and time on an NT based system, resulting from manually entered date and time values input by an operator via a 32-bit console app. Any ideas?..I may have to look further afield at Win32 API's, etc but I wondered if there was any way to do it via C initially. Merry Xmas to all !!!
5
3549
by: markus | last post by:
Hi, I have a question that deals with the standard c library VS (Unix) system calls. The question is: which header files (and functions) are part of the C library and which header files (and function calls) are part of the (Unix) system calls. The cause of my confusion is that for example stdio.h is considered
8
7856
by: Richard Lionheart | last post by:
Hi All, I tried using RegEx, but the compiler barfed with "The type of namespace 'RegEx' could not be found. Prior to this, I had the same problem with MatchCollection, but discovered it's in the namespace "System.Text.RegularExpressions;" and that namespace is, in turn, defined in the namespace "System", according to MSDN at http://msdn2.microsoft.com/en-us/library/c75he57e(en-us,VS.80).aspx. So adding "using...
1
4890
by: Mark Miller | last post by:
I just recently started getting the above error on a page I am posting MULTIPART/FORM-DATA. We have SoftArtisans FileUp component and Filter installed on the server in question and up until a day or so ago everything was working fine. I honestly can't remember changing anything since it was last working. But I tried reinstalling the .Net Framework along w/ the service pack, which didn't work. I also had v1.1 already installed but I hadn't...
1
2161
by: Sky | last post by:
Yesterday I was told that GetType(string) should not just be with a Type, but be Type, AssemblyName. Fair enough, get the reason. (Finally!). As long as it doesn't cause tech support problems down the line... What happens when my code is run on a station that only has framework 3.0 or 4.0, and this assembly, with version number defined for 2.0.0.0 , isn't available. ...breaks? Second question: Does an assembly's PublicKeyToken change...
10
3375
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably the worst I ever seen. I almost cannot find anything I need, including things I
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10639
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10383
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.