当前位置: 技术问答>linux和unix
linux如何启动就加载应用程序?
来源: 互联网 发布时间:2015-09-22
本文导语: 一直搞不定,多请指点,在线等。 | 可以在/etc/cd.d/init.d 这个目录下touch一个shell文件 中写上你要运行的程序的就可以了 再给那个文件加上+X 的属性就可以了。 要是要运行的是系统服务,...
一直搞不定,多请指点,在线等。
|
可以在/etc/cd.d/init.d 这个目录下touch一个shell文件
中写上你要运行的程序的就可以了
再给那个文件加上+X 的属性就可以了。
要是要运行的是系统服务,可以运行ntsysv后在中间选择。
中写上你要运行的程序的就可以了
再给那个文件加上+X 的属性就可以了。
要是要运行的是系统服务,可以运行ntsysv后在中间选择。
|
用sysinit命令
|
前三个星期论坛上好像讨论过这个问题,找找呀
|
在/etc/inittab或/etc/rc.d/rc.local里直接加。不过在/etc/inittab里加需要按他的格式.
|
(转)
#include
#include "utility.h"
int ReadIni( char filename[], char option[], char value[] )
{
FILE * fp;
char Buff[256], Tmp[256];
char * pch;
value[0]=0;
fp = fopen( filename, "r" );
if ( !fp )
return(FAIL);
while ( !feof(fp) )
{
if ( ! fgets( Buff, LINELEN, fp ) )
break;
DelSpace(Buff);
/* comment line */
if ( Buff[0] == '#' || strlen(Buff) == 0 )
continue;
/* Not content equale sign.*/
if ( !( pch = (char *)memchr( Buff, (int)'=', LINELEN ) ) )
continue;
strcpy( Tmp, pch+1 );
*pch = '';
DelSpace(Buff);
DelSpace(Tmp);
if ( memcmp( Buff, option, strlen(Buff) ) == 0 )
{
fclose(fp);
strcpy( value, Tmp );
return(OK);
}
}
fclose(fp);
return(FAIL);
}
int ReadINI( char filename[], char title[], char option[], char value[] )
{
FILE * fp;
char Buff[256], Tmp[256];
char * pch;
int iFindFlag;
value[0]=0;
fp = fopen( filename, "r" );
if ( !fp )
return(FAIL);
iFindFlag = 0;
while ( !feof(fp) )
{
if ( ! fgets( Buff, LINELEN, fp ) )
break;
DelSpace(Buff);
/* comment line */
if ( Buff[0] == '#' || strlen(Buff) == 0 )
continue;
else
if ( Buff[0] == '[' && Buff[strlen(Buff)-1] == ']' ) /* Title */
{
/* Not the first title needed, return FAIL. */
if ( iFindFlag )
break;
if ( ( memcmp( Buff+1, title, strlen(title) ) == 0 ) &&
( memcmp( Buff+1, title, strlen(Buff)-2 ) == 0 ) )
iFindFlag = 1;
continue;
}
else /* Value */
{
/* Just after Title is find, so Value can be find. */
if ( iFindFlag )
{
/* Not content equale sign.*/
if ( !( pch = (char *)memchr( Buff, (int)'=', LINELEN ) ) )
continue;
strcpy( Tmp, pch+1 );
*pch = '';
DelSpace(Buff);
DelSpace(Tmp);
if ( memcmp( Buff, option, strlen(Buff) ) == 0 )
{
fclose(fp);
strcpy( value, Tmp );
return(OK);
}
}
continue;
}
}
fclose(fp);
return(FAIL);
}
void DelSpace( char Str[] )
{
int ii, ij;
char Tmp[BUFFSIZE];
strcpy( Tmp, Str );
ii = strlen(Tmp);
for ( ; ii>0; ii-- )
if ( Tmp[ii-1] == ' ' || Tmp[ii-1] == 't' || Tmp[ii-1] == 'n' ||
Tmp[ii-1] == 'r' )
Tmp[ii-1] = '';
else
break;
for ( ij=0; ij0; ii-- )
{
if ( Tmp[ii-1] == ' ' || Tmp[ii-1] == 'r' || Tmp[ii-1] == 'n' ||
Tmp[ii-1] == 't' )
Tmp[ii-1] = '';
else
break;
}
for ( ij=0; ij
#include
#include "utility.h"
int ReadIni( char filename[], char option[], char value[] )
{
FILE * fp;
char Buff[256], Tmp[256];
char * pch;
value[0]=0;
fp = fopen( filename, "r" );
if ( !fp )
return(FAIL);
while ( !feof(fp) )
{
if ( ! fgets( Buff, LINELEN, fp ) )
break;
DelSpace(Buff);
/* comment line */
if ( Buff[0] == '#' || strlen(Buff) == 0 )
continue;
/* Not content equale sign.*/
if ( !( pch = (char *)memchr( Buff, (int)'=', LINELEN ) ) )
continue;
strcpy( Tmp, pch+1 );
*pch = '';
DelSpace(Buff);
DelSpace(Tmp);
if ( memcmp( Buff, option, strlen(Buff) ) == 0 )
{
fclose(fp);
strcpy( value, Tmp );
return(OK);
}
}
fclose(fp);
return(FAIL);
}
int ReadINI( char filename[], char title[], char option[], char value[] )
{
FILE * fp;
char Buff[256], Tmp[256];
char * pch;
int iFindFlag;
value[0]=0;
fp = fopen( filename, "r" );
if ( !fp )
return(FAIL);
iFindFlag = 0;
while ( !feof(fp) )
{
if ( ! fgets( Buff, LINELEN, fp ) )
break;
DelSpace(Buff);
/* comment line */
if ( Buff[0] == '#' || strlen(Buff) == 0 )
continue;
else
if ( Buff[0] == '[' && Buff[strlen(Buff)-1] == ']' ) /* Title */
{
/* Not the first title needed, return FAIL. */
if ( iFindFlag )
break;
if ( ( memcmp( Buff+1, title, strlen(title) ) == 0 ) &&
( memcmp( Buff+1, title, strlen(Buff)-2 ) == 0 ) )
iFindFlag = 1;
continue;
}
else /* Value */
{
/* Just after Title is find, so Value can be find. */
if ( iFindFlag )
{
/* Not content equale sign.*/
if ( !( pch = (char *)memchr( Buff, (int)'=', LINELEN ) ) )
continue;
strcpy( Tmp, pch+1 );
*pch = '';
DelSpace(Buff);
DelSpace(Tmp);
if ( memcmp( Buff, option, strlen(Buff) ) == 0 )
{
fclose(fp);
strcpy( value, Tmp );
return(OK);
}
}
continue;
}
}
fclose(fp);
return(FAIL);
}
void DelSpace( char Str[] )
{
int ii, ij;
char Tmp[BUFFSIZE];
strcpy( Tmp, Str );
ii = strlen(Tmp);
for ( ; ii>0; ii-- )
if ( Tmp[ii-1] == ' ' || Tmp[ii-1] == 't' || Tmp[ii-1] == 'n' ||
Tmp[ii-1] == 'r' )
Tmp[ii-1] = '';
else
break;
for ( ij=0; ij0; ii-- )
{
if ( Tmp[ii-1] == ' ' || Tmp[ii-1] == 'r' || Tmp[ii-1] == 'n' ||
Tmp[ii-1] == 't' )
Tmp[ii-1] = '';
else
break;
}
for ( ij=0; ij