和* n * x交谈 [英] Talking to *n*x

查看:58
本文介绍了和* n * x交谈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,c最初设计用于与unix操作系统一起编写和通信
。直到最近我才忽略了这一点,因为我的b $ b大多是与opengl极化。我现在有兴趣直接与操作系统(实际上是linux)进行交互

我想知道是否有人有任何建议/网址。具体来说,我已经找到了

system()函数,它几乎可以满足我的需求。但是,虽然我可以

做类似


系统(cd / me / home / somedir);

system(mkdir somesubdir);


这很酷。但是如果我想从/ OS获取信息呢?

说我只想获得ls命令的输出。我是否必须使用system()调用和环境变量来完成

?如果是这样的话,我可以写一个shell脚本。

Anyhoo,ta。

I understand that c was originally designed to write and communicate
with the unix operating system. Until recently I ignored this, as I
was mostly polaying with opengl. I am now interested in interacting
more directly with the operating system (actually linux) and I was
wondering if anyone has any advice/urls. Specifically, I''ve found the
system() function, which almost does what I want. But, while I could
do something like

system("cd /me/home/somedir");
system("mkdir somesubdir");

which is cool. But what if I want to get information /from/ the OS?
say I just want to get the output of a ls command. Do I have to do it
all with system() calls and environment variables? If so, I may as
well write a shell script.
Anyhoo, ta.

推荐答案

robbie carlton< ro ************ @ hotmail.com>写道:
robbie carlton <ro************@hotmail.com> wrote:
我知道c最初是为了与unix操作系统编写和通信而设计的。直到最近,我忽略了这一点,因为我很大程度上使用opengl极化。我现在有兴趣更直接地与操作系统(实际上是linux)交互,我想知道是否有人有任何建议/网址。具体来说,我已经找到了
system()函数,它几乎可以实现我想要的功能。但是,虽然我可以做一些像
system(cd / me / home / somedir);
system(mkdir somesubdir);
很酷。但是,如果我想从/ OS获取信息怎么办?
说我只想获得ls命令的输出。我是否必须使用system()调用和环境变量来完成所有操作?如果是这样,我可能会好好写一个shell脚本。
I understand that c was originally designed to write and communicate
with the unix operating system. Until recently I ignored this, as I
was mostly polaying with opengl. I am now interested in interacting
more directly with the operating system (actually linux) and I was
wondering if anyone has any advice/urls. Specifically, I''ve found the
system() function, which almost does what I want. But, while I could
do something like system("cd /me/home/somedir");
system("mkdir somesubdir"); which is cool. But what if I want to get information /from/ the OS?
say I just want to get the output of a ls command. Do I have to do it
all with system() calls and environment variables? If so, I may as
well write a shell script.




除了system()以外的任何东西,你都会离开标准C的领域。

所以最好在适当的新闻组中询问这类问题

如comp.unix.programmer或comp.os.linux.development.apps。


< OT>

看看popen(3)函数,但是opendir(3),readdir(3)

和closedir(3)也可能对你有意思。

< / OT>

问候,Jens

-

\ Jens Thoms Toerring ___ Je***********@physik.fu-berlin .de

\ __________________________ http://www.toerring .de


robbie carlton写道:
robbie carlton wrote:
我知道c最初的目的是为了编写和交流
unix操作系统。直到最近,我忽略了这一点,因为我很大程度上使用opengl极化。我现在有兴趣更直接地与操作系统(实际上是linux)交互,我想知道是否有人有任何建议/网址。具体来说,我已经找到了
system()函数,它几乎可以实现我想要的功能。但是,虽然我可以做

系统(cd / me / home / somedir);
系统(mkdir somesubdir);

这很酷。但是,如果我想从/ OS获取信息怎么办?
说我只想获得ls命令的输出。我是否必须使用system()调用和环境变量来完成所有操作?如果是这样,我可能会写好shell脚本。
Anyhoo,ta。
I understand that c was originally designed to write and communicate
with the unix operating system. Until recently I ignored this, as I
was mostly polaying with opengl. I am now interested in interacting
more directly with the operating system (actually linux) and I was
wondering if anyone has any advice/urls. Specifically, I''ve found the
system() function, which almost does what I want. But, while I could
do something like

system("cd /me/home/somedir");
system("mkdir somesubdir");

which is cool. But what if I want to get information /from/ the OS?
say I just want to get the output of a ls command. Do I have to do it
all with system() calls and environment variables? If so, I may as
well write a shell script.
Anyhoo, ta.




< OT>

有一本厚厚的书,UNIX环境下的高级编程

由已故的理查德史蒂文斯写的关于这个主题的文章。函数

system()很有意思,但在很多情况下不是(最有效的)

的方式。


一切顺利,


案例

< / OT>



<OT>
There''s a thick book, "Advanced Programming in the UNIX Environment"
written by the late Richard Stevens about this subject. The function
system() is interesting, but in many cases not the (most efficient)
way to go.

All the best,

Case
</OT>


< a href =mailto:ro ************ @ hotmail.com> ro ************ @ hotmail.com (罗比卡尔顿)写道:
ro************@hotmail.com (robbie carlton) writes:
我知道c最初是为了与unix操作系统编写和通信而设计的。直到最近,我忽略了这一点,因为我很大程度上使用opengl极化。我现在有兴趣更直接地与操作系统(实际上是linux)交互,我想知道是否有人有任何建议/网址。


新闻组comp.unix.programmer有建议和网址(例如他们的常见问题

对你很有意思)。但是,Unix和它的C接口部分特定于系统的部分是非偏离主题的,所以请在

comp.unix.programmer中询问。

具体来说,我找到了system()函数,它几乎完成了我想要的。但是,虽然我可以做一些像

系统(cd / me / home / somedir);
system(mkdir somesubdir);


第一个函数调用对Unix下的调用程序没有影响。

第二个可能有效,但效率很低。

这很酷。但是,如果我想从/ OS获取信息怎么办?
说我只想获得ls命令的输出。我是否必须使用system()调用和环境变量来完成所有操作?
I understand that c was originally designed to write and communicate
with the unix operating system. Until recently I ignored this, as I
was mostly polaying with opengl. I am now interested in interacting
more directly with the operating system (actually linux) and I was
wondering if anyone has any advice/urls.
The newsgroup comp.unix.programmer has advice and URLs (e.g. their FAQ
will be interesting for you). However, Unix and the system-specific
parts of its interface to C are off-topic here, so please ask in
comp.unix.programmer.
Specifically, I''ve found the system() function, which almost does what
I want. But, while I could do something like

system("cd /me/home/somedir");
system("mkdir somesubdir");
The first function call has no effect on the calling program under Unix.
The second is likely to work, but very inefficient.
which is cool. But what if I want to get information /from/ the OS?
say I just want to get the output of a ls command. Do I have to do it
all with system() calls and environment variables?




编号请在comp.unix.programmer中查询详情。


马丁

-

, - 。 Martin Dickopp,德国德累斯顿,=, - _-。 =。

/, - ) http://www.zero -based.org/ ((_ /)oo(\_))

\` - ''` - ''(。)` - ''

` - 。 Debian,GNU操作系统的一种变体。 \_ /



No. Please ask in comp.unix.programmer for details.

Martin
--
,--. Martin Dickopp, Dresden, Germany ,= ,-_-. =.
/ ,- ) http://www.zero-based.org/ ((_/)o o(\_))
\ `-'' `-''(. .)`-''
`-. Debian, a variant of the GNU operating system. \_/


这篇关于和* n * x交谈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆