如何从那里然后从stdin读取值? [英] How to read values from stdin then and there?

查看:128
本文介绍了如何从那里然后从stdin读取值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是Linux环境的新手.我正在尝试让用户执行所有命令并将其放置在文件中.我想做的是从stdin读取值并将其直接放在一个文件中.但是我不知道如何使用脚本从stdin读取.

请帮帮我..
在此先感谢:)

-
Yugeshkumar V

Hi,

I''m new to Linux environment. I''m trying to get all commands executed by user and place it in a file. What I thought to do is read the value from stdin & directly place it in one file. But I don''t know how to read from stdin using script.

Please help me..
Thanks in advance:)

--
Yugeshkumar V

推荐答案

该外壳程序具有一个名为脚本"的命令,该命令将输入​​和输出保存到文本文件中.
http://www.linuxhowtos.org/Tips%20and%20Tricks/using_script.htm [ ^ ]
The shell has a command called "script" which saves input and output to a text file.

http://www.linuxhowtos.org/Tips%20and%20Tricks/using_script.htm[^]


使用"bash"作为所有用户的登录shell. bash正在将所有命令写入用户/home
的bash_history
但是至少有一个陷阱. bash_history是用户可写的,可以修改.同样适用于命令脚本".
Use ''bash'' as login shell for all users. bash is writing all commands to bash_history at users /home

But there''s at least one pitfall. bash_history is writable by the user and can be modified. Same applies to command ''script''.


您将需要编写自己的shell,该命令会将所有命令记录到文件中.或者,修改系统上的默认用户外壳程序以执行相同的操作,并确保用户无法切换到其他方法之一.
You would need to write your own shell which logs all commands to a file. Or, modify the default user shell on your system to do the same, and ensure that users are not able to switch to one of the alternatives.


这篇关于如何从那里然后从stdin读取值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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