473,587 Members | 2,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run Dos Command in CLR

6 New Member
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.
Feb 13 '07 #1
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
Feb 13 '07 #2
Motoma
3,237 Recognized Expert Specialist
Quick question: what OS are you trying to code this for?
Feb 13 '07 #3
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
Feb 13 '07 #4
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.
Feb 13 '07 #5
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
Feb 13 '07 #6
Ofanek
6 New Member
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 ?
Feb 13 '07 #7
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.
Feb 13 '07 #8
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
Feb 13 '07 #9
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?
Feb 13 '07 #10

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

Similar topics

1
2544
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...
8
1333
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...
2
9280
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...
2
6666
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"
34
6839
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
13
4481
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:
0
1692
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...
3
18699
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...
51
4118
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.
0
7918
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...
0
8206
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. ...
0
8220
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...
0
6621
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...
1
5713
isladogs
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...
0
3840
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...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2353
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
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.