China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 01:13
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » How to call DOS system commands in C without showing the command line? View 2,001 Replies 12
Original Poster Posted 2003-08-05 00:00 ·  中国 浙江 杭州 电信
初级用户
Credits 121
Posts 5
Joined 2003-07-31 00:00
23-year member
UID 7842
Gender Male
Status Offline
In C, when using execl to call another application under DOS, the command line gets displayed. How can I make that information not show up?
Just like when using the sys function to call the copy command, the screen shows *** file copied. How can I keep that sentence from being displayed
Floor 2 Posted 2003-08-06 00:00 ·  美国 肯塔基州 费耶特县 列克星敦 Charter_Communications
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
Try adding ">nul" at the end. . .
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 3 Posted 2003-08-07 00:00 ·  中国 浙江 杭州 电信
初级用户
Credits 121
Posts 5
Joined 2003-07-31 00:00
23-year member
UID 7842
Gender Male
Status Offline
I tried it. It doesn't work. Thank you anyway
Floor 4 Posted 2003-08-09 00:00 ·  中国 上海 电信
初级用户
Credits 106
Posts 1
Joined 2003-07-26 00:00
23-year member
UID 7571
Gender Male
Status Offline
Use echo
Floor 5 Posted 2003-08-10 00:00 ·  中国 陕西 西安 教育网
高级用户
★★
OS/2女孩
Credits 639
Posts 183
Joined 2003-06-14 00:00
23-year member
UID 5148
Gender Female
Status Offline
Under DOS 7.1, using ECHO can remove the COPY XXX shown when doing system("copy xxx".
Using system("copy xxx >nul"; should remove that failed..... line.
I haven't tried exec calls.

There's another possibility: you're using an EXE file compiled with DJGPP. Its redirection is a bit different from ordinary
DOS programs, so try using system("XXX XXX >>NUL" for redirection. If that still doesn't work,
come back and ask again. If it really won't work, send me what you want to call, and after I test it I'll send you the source code.
REM 喜欢DOS,因为它的简单
REM 喜欢OS/2,因为它不再矫饰
REM 喜欢BASIC,因为它并不幼稚
REM 喜欢GNU,因为它杂乱无章
Floor 6 Posted 2003-08-10 00:00 ·  中国 陕西 西安 教育网
高级用户
★★
OS/2女孩
Credits 639
Posts 183
Joined 2003-06-14 00:00
23-year member
UID 5148
Gender Female
Status Offline
Oh right, I forgot to ask. What DOS version are you using? What compiler system?
REM 喜欢DOS,因为它的简单
REM 喜欢OS/2,因为它不再矫饰
REM 喜欢BASIC,因为它并不幼稚
REM 喜欢GNU,因为它杂乱无章
Floor 7 Posted 2003-08-11 00:00 ·  中国 浙江 杭州 电信
初级用户
Credits 121
Posts 5
Joined 2003-07-31 00:00
23-year member
UID 7842
Gender Male
Status Offline
I'm using MS-DOS 6.22. Do I have to use DOS 7.1?
What I'm calling is an application made by someone else, used for FTP uploads under DOS.
Floor 8 Posted 2003-08-12 00:00 ·  中国 湖北 武汉 联通
银牌会员
★★★
Credits 1,681
Posts 512
Joined 2003-08-02 00:00
22-year member
UID 7953
Gender Male
Status Offline
">" and ">>" are redirection symbols. They can only redirect program output, and can't do anything about system prompts like "Bad command or file name".
Somehow somewhere I've got to choose.
No matter if it is win or lose.
Floor 9 Posted 2003-08-17 00:00 ·  中国 陕西 西安 教育网
高级用户
★★
OS/2女孩
Credits 639
Posts 183
Joined 2003-06-14 00:00
23-year member
UID 5148
Gender Female
Status Offline
With ECHO OFF as a prerequisite, add the redirection. Everything will become absolutely silent. Hehe. . . .
REM 喜欢DOS,因为它的简单
REM 喜欢OS/2,因为它不再矫饰
REM 喜欢BASIC,因为它并不幼稚
REM 喜欢GNU,因为它杂乱无章
Floor 10 Posted 2003-08-17 00:00 ·  中国 安徽 滁州 天长市 电信
银牌会员
★★★
Credits 1,835
Posts 648
Joined 2002-11-08 00:00
23-year member
UID 197
Gender Male
Status Offline
The following is quoted from iceboy's post at 2003-8-12 14:55:36:
">" and ">>" are redirection symbols. They can only redirect program output, and can't do anything about system prompts like "Bad command or file name".

Also, program error messages can't be redirected either, for example:

C:\>copy a.txt d:\ >nul
File not found - a.txt

I copied this from a DOS window
Floor 11 Posted 2003-08-18 00:00 ·  中国 陕西 西安 电信
高级用户
★★
OS/2女孩
Credits 639
Posts 183
Joined 2003-06-14 00:00
23-year member
UID 5148
Gender Female
Status Offline
Yeah, that's right. But under system and EXEC() calls,
it really is completely silent.

We're not discussing redirection itself, we're discussing "the use of redirection in programming".

The discussion should address the OP's question!!
REM 喜欢DOS,因为它的简单
REM 喜欢OS/2,因为它不再矫饰
REM 喜欢BASIC,因为它并不幼稚
REM 喜欢GNU,因为它杂乱无章
Floor 12 Posted 2003-08-18 00:00 ·  中国 陕西 西安 电信
高级用户
★★
OS/2女孩
Credits 639
Posts 183
Joined 2003-06-14 00:00
23-year member
UID 5148
Gender Female
Status Offline
Sigh, DOS 6.22 or DOS 7, that doesn't really matter. . . . . . . . . .

Just send the program directly to me, and I'll try it with all the most popular compiler systems. Wouldn't that solve it??
I guess you're using TURBO C, right? Or BC?

If you're using BC, you can also redirect ERROR output and do it with C++ streams. There are plenty of ways.
REM 喜欢DOS,因为它的简单
REM 喜欢OS/2,因为它不再矫饰
REM 喜欢BASIC,因为它并不幼稚
REM 喜欢GNU,因为它杂乱无章
Floor 13 Posted 2003-08-18 00:00 ·  中国 安徽 滁州 天长市 电信
银牌会员
★★★
Credits 1,835
Posts 648
Joined 2002-11-08 00:00
23-year member
UID 197
Gender Male
Status Offline
The following is quoted from lemonhall's post at 2003-8-18 11:34:57:
Yeah, that's right. But under system and EXEC() calls,
it really is completely silent.

We're not discussing redirection itself, we're discussing "the use of redirection in programming"

The discussion should address the OP's question!!

Hehe, sorry about that I forgot this was the programming section ]
Forum Jump: