Hi there,
Can someone help me with this? I am trying to run a DOS commad as dir but I need it to be done using another way rather than --> system("dir")
Also, I want to catch the error message that come out from running any tool or command ( but not the standard commands as dir) , for example , I have the gzip and when I run it for a crashed file it gives me on the console a message stating what is the error , how can I catch this error ?
Thanks
Ossama F.
22 6962 AdrianH 1,251
Recognized Expert Top Contributor
Hi there,
Can someone help me with this? I am trying to run a DOS commad as dir but I need it to be done using another way rather than --> system("dir")
Also, I want to catch the error message that come out from running any tool or command ( but not the standard commands as dir) , for example , I have the gzip and when I run it for a crashed file it gives me on the console a message stating what is the error , how can I catch this error ?
Thanks
Ossama F.
I'm not sure, but I think this is better in the .NET forum. However, why do you want something other than system("dir"), so that you can grab the output from the execution?
If so, then fork() comes to mind. But its been a while. You would have to close the stdout and stderr file handles (not the FILE descriptors) open 2 pipes and then by using dup() on those two pipes to replace the closed stdout and stderr handles. The FILE descriptors will then be redirected to the pipes which would be accessable by both child and parent process since the child inheirits those handles.
See: Hope this helps,
Adrian
Motoma 3,237
Recognized Expert Specialist
Quick question: what OS are you trying to code this for?
AdrianH 1,251
Recognized Expert Top Contributor
Quick question: what OS are you trying to code this for?
Shouldn't matter, Windoze is POSIX compliant. :)
Adrian
Motoma 3,237
Recognized Expert Specialist
Shouldn't matter, Windoze is POSIX compliant. :)
Adrian
Windows doesn't have an 1:1 equivalent of fork() however...And I'm not sure about dup() or pipe() either.
AdrianH 1,251
Recognized Expert Top Contributor
Windows doesn't have an 1:1 equivalent of fork() however...And I'm not sure about dup() or pipe() either.
Awww, your throwing cold water on my fun. :(
I really think since this user is referring to the CLR, this should be moved to the .NET forum.
Adrian
My OS is windows. Actually , I always run the DOS commands through system ( ) but I have some tools as gzip and I want to catch the error messages from the console. I need it to be done in .NET if that possible ?
Motoma 3,237
Recognized Expert Specialist
Awww, your throwing cold water on my fun. :(
I really think since this user is referring to the CLR, this should be moved to the .NET forum.
Adrian
Awww...I saw the words DOS and CLR and interpreted it as CLI :P Being in the C/C++ forum pushed me to that idea as well.
Perhaps, Ofanek, if you could tell us what language you are using, we will be able to settle this little dispute, and land you in the correct forum.
AdrianH 1,251
Recognized Expert Top Contributor
Awww...I saw the words DOS and CLR and interpreted it as CLI :p Being in the C/C++ forum pushed me to that idea as well.
Perhaps, Ofanek, if you could tell us what language you are using, we will be able to settle this little dispute, and land you in the correct forum.
CLI can still refer to .NET (Common Language Infastructure)
Adrian
Motoma 3,237
Recognized Expert Specialist
CLI can still refer to .NET (Common Language Infastructure)
Adrian
It can also mean Command Line Interface.
P.S. Gonna hit 100 on this thread?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: TEK |
last post by:
Hello
I'm wondering if anyone out there might give some
input/suggestions/viewpoints around the Command pattern.
In my case, the number one priority for using the pattern is undo support.
Some now, a lot more in the future.
I think I have a pretty good understanding about how the command pattern is
tought to work, however during...
|
by: Siemel Naran |
last post by:
Hi. I'm writing a command shell that reads commands from standard input.
At this point I have the command in a std::string. Now I want to execute
this command in the shell. From the Borland newsgroups I learned that there
is a function in stdlib.h called system.
int system(const char *command);
First question, is the system command...
|
by: Chris Bolus |
last post by:
I'm a teacher using MS Access on an RMConnect 2.4 network. On some
workstations both I and my students sometimes get an error message
when attempting to insert a command button on a form which reads
"Invalid
use of null". The remainder of the options in the Command Button
Wizard are then unavailable and
the button wil not work.
The only...
|
by: micahstrasser |
last post by:
I have been trying for days to send a command to the command prompt
through the shell() function in vb.net. For some reason it is not
working. Here is the code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim command As String
command = "systeminfo > C:\temp\sysinfo.txt"
|
by: Roman Mashak |
last post by:
Hello, All!
I'm implementing simple CLI (flat model, no tree-style menu etc.). Command
line looks like this: <command> <param1> <param2> ... <paramN> (where
N=1..4)
And idea is pretty simple:
1) get whole string of input line
2) preset table of strings matching <command>
3) preset table of function calls
| |
by: Chris Carlen |
last post by:
Hi:
Having completed enough serial driver code for a TMS320F2812
microcontroller to talk to a terminal, I am now trying different
approaches to command interpretation.
I have a very simple command set consisting of several single letter
commands which take no arguments. A few additional single letter
commands take arguments:
|
by: czerwww |
last post by:
Can someone please help me? I have class for database connection and I need set command.commandTimeout. How can I do that?
Code:
Imports System.Data.SqlClient
Imports System.Data
Public Class Db
Private Shared _ConnString As String = ""
Private Shared _Connection As SqlConnection
Public Shared Sub SetConnectionString(ByVal...
|
by: creative1 |
last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however, working with complex reports is tricky
Assumption: Reader of this article have basic knowledge of creating data reports.
Creating a Parent-Child...
|
by: Ojas |
last post by:
Hi!,
I just out of curiosity want to know how top detect the client side
application under which the script is getting run. I mean to ask the
how to know whether the script is running under Command Prompt or
Browser or some other application?
Ojas.
|
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...
|
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. ...
| |
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |