本文介绍了尝试从shell脚本进行freebsd更新时,如何假装成tty?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们通常在系统安装后使用自定义脚本来设置新的FreeBSD机器,该机器从端口树安装工具并设置系统环境.我们还需要通过freebsd-update将新安装的FreeBSD-8.2机器自动更新为FreeBSD-8.2p3.据我所知,freebsd-update不允许我从没有"cron"选项的shell脚本中执行它.因此,我尝试预加载一个自定义程序来欺骗freebsd-update:

We usually use a custom script to setup new FreeBSD machines after system installation, which installs tools from ports tree and sets up system environment.we also need to automate update newly installed FreeBSD-8.2 machines to FreeBSD-8.2p3 by freebsd-update. As I know, freebsd-update doesn't allow me to execute it from a shell script without a "cron" option. So I try to preload a custom program to cheat freebsd-update:

${CAT} > /tmp/isatty.c     <<EOF                                                                                                                                                                                         
int isatty(const int fd) { return 1; }                                                                                                                                                                               
EOF                                                                                                                                                                                                                  
${CC} -shared -fPIC -o /tmp/isatty.so     /tmp/isatty.c                                                                                                                                                                          
${ENV} LD_PRELOAD=/tmp/isatty.so LESS="-E" ${FREEBSD_UPDATE} fetch install < /dev/null   

通过此调整,我可以从自定义脚本成功运行freebsd-update,但是在freebsd-installer从更新服务器获取文件后,我得到了以下错误消息:

with this tweak, I can sucessfully run freebsd-update from my custom script, but after the freebsd-installer fetched files from update server, I got this error message:

Fetching metadata signature for 8.3-RELEASE from update5.FreeBSD.org... done.
Fetching metadata index... done.
Fetching 2 metadata files... gunzip: standard input is a terminal -- ignoring
metadata is corrupt.

我有机会解决这个问题吗?

Do I have any chance to solve this?

推荐答案

此实用工具可能就是您需要的:空-运行伪终端(PTY)下的访问过程和应用

This utility may be what you need: empty - run processes and applications under pseudo-terminal (PTY)

这样,您应该可以从脚本启动freebsd-update.

This way you should be able start freebsd-update from script.

这篇关于尝试从shell脚本进行freebsd更新时,如何假装成tty?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 14:04