免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 4092 | 回复: 13
打印 上一主题 下一主题

如何在出现登录界面之前启动一个应用程序 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-07-26 14:38 |只看该作者 |倒序浏览
如果linux采用图形界面登录,在出现登录界面之前我想启动一个应用程序,哪位能给点建议

谢谢

论坛徽章:
0
2 [报告]
发表于 2006-07-26 15:18 |只看该作者

firstboot

我刚才在/etc/init.d/下找到了firstboot程序,这个是那个程序
只运行一次
但是现在我想如果每次登录都要启动我的应用程序,注销,重启都要启动我的应用程序,该在哪里添加呢
我的程序是用c开发的图形界面程序,是来完成设定用户添加功能的

论坛徽章:
0
3 [报告]
发表于 2006-07-26 15:24 |只看该作者
放到rc.local里面应该可以吧

论坛徽章:
0
4 [报告]
发表于 2006-07-26 15:46 |只看该作者
直接指定到我的程序名的一个完整路径就可以吗?
我在最后一行加入
/usr/local/bin/firstboot
重启后没有反应

论坛徽章:
0
5 [报告]
发表于 2006-07-26 16:24 |只看该作者
runlevel 5 我沒试过    你试试 runlevel 3  应该可以


我上面说的方法在runlevel 5 下运行一个脚本(*.sh)没问题

[ 本帖最后由 gothicane 于 2006-7-26 16:25 编辑 ]

论坛徽章:
0
6 [报告]
发表于 2006-07-26 17:38 |只看该作者
这个我试了,运行一个叫本是可以的
我写了一个shell,只有一个echo语句,然后我再rc.local中加入这句话,然后加入执行我那个应用程序的完成路径,然后再把我的shell执行一边,就是这样:
/lianxy/shell_test/log.sh >/tmp/logtest.txt
/usr/local/bin/firstboot >/tmp/logerr.txt
/lianxy/shell_test/log.sh >>/tmp/logtest.txt
,然后我发现,那个logtest。txt内容如下
*****************hello everyone********************
*****************hello everyone********************
这说明我的shell执行了两次,可是中间的那个图形界面的程序却不知道怎么回事
那个/tmp/logerr.txt内容是
(firstboot:2007): Gtk-WARNING **: cannot open display:

不知道我这样说能看明白吗?

论坛徽章:
0
7 [报告]
发表于 2006-07-26 18:11 |只看该作者
我把刚才的那个shell做了一个软连接,然后放在rc5。d/
目录下面,也是可以正常启动的
但是就释放我那个图形界面的窗口不行

论坛徽章:
0
8 [报告]
发表于 2006-07-26 21:59 |只看该作者
原帖由 艾因思念 于 2006-7-26 17:38 发表
这个我试了,运行一个叫本是可以的
我写了一个shell,只有一个echo语句,然后我再rc.local中加入这句话,然后加入执行我那个应用程序的完成路径,然后再把我的shell执行一边,就是这样:
/lianxy/shell_test/lo ...



调用Gtk库可能需要启动XWINDOW,请确定你的XWINDOW已经启动了。

论坛徽章:
0
9 [报告]
发表于 2006-07-27 08:50 |只看该作者
我不知道那个时候XWINDOW是否启动了,但是我想写一段代码启动xwindows,然后启动我的程序,我想就没有问题了
可是,我不会写
哪位能帮帮忙?

论坛徽章:
0
10 [报告]
发表于 2006-07-27 09:17 |只看该作者
#!/bin/bash
#
# firstboot:         Starts the firstboot druid if it hasn't been run before
#
# chkconfig: 35 95 95
#
# description:       Firstboot is a druid style program that runs on the first time \
#                    a machine is booted after install.  It checks for the existence \
#                    of an /etc/sysconfig/firstboot file.  If it doesn't find the file, \
#                    then the firstboot program needs to run.  If it finds the file, \
#                    firstboot will not be run.
#                    If /etc/reconfigSys exists, run the reconfiguration
#                     program and remove /etc/reconfigSys when done.
#
#                    Also will run if 'reconfig' is on the kernel cmdline.
#

unset LC_MESSAGES
[ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
[ -z "${CONSOLETYPE:-}" ] && CONSOLETYPE="`/sbin/consoletype`"
export LANG

# Source function library.
. /etc/init.d/functions

FILENAME=/etc/sysconfig/firstboot
LOCKFILE=/var/lock/subsys/firstboot

[ -z "$HOME" ] && export HOME=/

case "$1" in
start)
        action=run

   [ -f "$LOCKFILE" ] && exit 0

        if [ -f "$FILENAME" ] && ! grep -q '^RUN_FIRSTBOOT=YES' "$FILENAME"; then
            action=skip
        fi

        if grep -i reconfig /proc/cmdline >/dev/null || [ -f /etc/reconfigSys ]; then
            action=reconfig
        fi

        [ $action = skip ] && exit 0

        runlevel=$(set -- $(runlevel); eval "echo \$$#" )
        if grep -q "^id:5:initdefault:" /etc/inittab && [ "x$runlevel" = x5 ]; then
            if [ ! -f /etc/X11/xorg.conf -a ! -f /etc/X11/XF86Config ] ; then
                echo -n $"X is not configured.  Running system-config-display"
                /usr/bin/system-config-display
                echo -n $"X is now configured.  Starting Setup Agent"
            fi
        fi

        if [ $action = reconfig ]; then
            echo -n $"Running system reconfiguration tool"
            /usr/sbin/firstboot --reconfig
            rm -f /etc/reconfigSys
            exit 0
        fi

   touch $LOCKFILE
        /usr/sbin/firstboot
        RETVAL=$?

        if [ "$RETVAL" -eq 0 ]; then
            action "" /bin/true
        else
            action "" /bin/false
        fi

        exit 0
        ;;

stop)
   rm -f $LOCKFILE
   ;;
esac

exit $RETVAL
这个是/etc/init.d/firstboot的脚本,这个程序在安装完linux之后第一次登录的时候会运行,这个程序也是图形界面的,也就是说它应该启动了图形界面需要的东西,所以我想从这段代码中取出启动图形界面的东西,然后加上我的程序的绝对路径,就应该可以运行了,但是我做昨天尝试的代码是这样的:

if [ ! -f /etc/X11/xorg.conf -a ! -f /etc/X11/XF86Config ] ; then
        echo -n $"X is not configured.  Running system-config-display"
        /usr/bin/system-config-display
        echo -n $"X is now configured.  Starting Setup Agent"
fi
/lianxy/shell_test/windowsproject
这段代码执行后,启动的时候就像死机一样,不懂了,ssh访问也特别慢,好像有什么占用了所有的cpu或者内存
不知道这个能不能有什么用,请指点

[ 本帖最后由 艾因思念 于 2006-7-27 10:10 编辑 ]
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP