Software 版 (精华区)

发信人: cgl (老顽童), 信区: Software
标  题: 自动登录script
发信站: 紫 丁 香 (Thu Nov  5 14:29:08 1998), 转信





/////////////////////////////////////////////////////////////////

//                                 It's a code-available freeware

//  AL.SLT

//                      Autolog v5.0 beta                   能用

//                    ---- Run under TELIX                 就行版

//

//  在指定时间段内自动登录HOMEPCUG,NEWMOON和DATAFAST,并收发信件

//

//                                       Copyright(C)1995,Softech

//                                                by Quarway Migh

/////////////////////////////////////////////////////////////////

//

//  请根据实际情况修改相关参数,然后进入TELIX目录运行

//                        CS AL

//  对此文件进行编译. 在进入TELIX后按ALT+G,AL运行

/////////////////////////////////////////////////////////////////


int c_homepcug;     // 是否登录HOMEPCUG ---- 0 登录, 1 不登录

int c_datafast;     // 是否登录DATAFAST ---- 0 登录, 1 不登录

int c_newmoon;      // 是否登录NEWMOON  ---- 0 登录, 1 不登录

int pp;

int begin_time=1;   // 指定从几点钟开始拨号(24小时制)

int end_time=2;     // 指定到几点钟还没上站就停止拨号(24小时制)

int max_retry=50;   // 指定最多可以重拨多少次

int int_time=0;   // 间隔1/10秒数

int wait_menu=100;  // 在进入主菜单前最多回车次数

int wait_int=3;     // 判断是否进入主菜单的间隔秒数

int x_homepcug,x_datafast,x_newmoon;

int now;

str replyfile[64];


/////////////////////////////////////////////////////////////////

main()

{

    int loop=1,ik;


    _zmod_auto=0;

    _scr_chk_key=1;

    _up_dir="..\BWAVE\UPLOAD";   // 蓝波的UPLOAD路径

    _down_dir="..\BWAVE\DOWN";   // 蓝波的DOWNLOAD路径


    while(loop)

    {

        while((thour(curtime())>=end_time||thour(curtime())<begin_time)&&loop)

        {

            printsc("^MWaiting for ");      //  等待指定的时间的到来

            printn(begin_time);

            printsc(":00am...  ");

            printn(thour(curtime()));

            printsc(":");

            printn(tmin(curtime()));

            printsc(":");

            printn(tsec(curtime()));

            printsc("   ");

            ik=inkey();

            if(ik==27||ik==13)              //  可以按ESC或回车退出

            {

                loop=0;

                prints("^MAbort");

            }

        }

        if(loop)

        {

            printsc("^MIt's ");             // 时间到了

            printn(begin_time);

            prints(":00am now.");

            loop=0;

            callit();                       // 开始呼叫

            prints("^MEnd of call");

        }

    }

    exittelix(0,1);     // 退出TELIX

}


/////////////////////////////////////////////////////////////////

//  呼叫过程

callit()

{

    int j;


    c_homepcug=0;   // 总是登录HOMEPCUG

    c_datafast=1;

    c_newmoon=0;


    x_homepcug=0;

    x_datafast=0;

    x_newmoon=0;


    j=dow(curtime());   // 得到当前是星期几


//    if(j==7) c_newmoon=0;

//    if(j==7) c_datafast=0;

//    if(j==7) c_homepcug=0;


    usagelog("LOG.LOG");    // 打开一个LOG文件,记录拨号和文件UP/DOWN LOAD过程

    capture("CAP.CAP");     // 打开一个文件把接到的所有屏幕记录下来,

                            // 以便出现问题时查看错误所在.


    cputs_tr("atx0dt#54*1048#^M");

    delay(70);

    cputs_tr("ath0^M");


    while(!c_homepcug||!c_datafast||!c_newmoon)

    {

        if(!c_homepcug)     // 如果要登录HOMEPCUG

        {

            if(thour(curtime())>=end_time)   // 如果到指定时间还不能上站

                return;                     // 那就算了

            prints("^MDial HOMEPCUG...");

            delay(30);                      // 延时3秒,如果按ESC或回车

            if(inkey()==27||inkey()==13)    // 则跳过HOMEPCUG

            {

                c_homepcug=1;

                prints("^MSkip HOMEPCUG");

            }

            if(!c_homepcug)

            {

                homepcug();     // HOMEPCUG的登录过程


                if(c_homepcug==0)   // 没接通

                    x_homepcug=x_homepcug+1;


                if(x_homepcug>=max_retry)   // 超过最多重试次数

                    c_homepcug=3;           // 退出

                else

                    delay(int_time);             // 否则延时1分钟


                if(c_homepcug==1)   // 完成全过程

                    prints("^MHOMEPCUG OK");


                if(c_homepcug==2)   // 夭折

                    prints("^MHOMEPCUG canceled");

            }

        }


        if(!c_datafast)     // 参考上述有关HOMEPCUG的注释

        {

            if(thour(curtime())>=end_time)  return;

            prints("^MDial DATAFAST...");

            delay(30);

            if(inkey()==27||inkey()==13)

            {

                c_datafast=1;

                prints("^MSkip DATAFAST");

            }

            if(!c_datafast)

            {

                datafast();


                if(c_datafast==0)   // 没接通

                    x_datafast=x_datafast+1;


                if(x_datafast>=max_retry)

                    c_datafast=3;

                else

                    delay(int_time);


                if(c_datafast==1)

                    prints("^MDATAFAST OK");


                if(c_datafast==2)

                    prints("^MDATAFAST canceled");

            }

        }


        if(!c_newmoon)      // 参考上述有关HOMEPCUG的注释

        {

            if(thour(curtime())>=end_time)  return;

            prints("^MDial NEWMOON...");

            delay(30);

            if(inkey()==27||inkey()==13)

            {

                c_newmoon=1;

                prints("^MSkip NEWMOON");

            }

            if(!c_newmoon)

            {

                newmoon();


                if(c_newmoon==0)   // 没接通

                    x_newmoon=x_newmoon+1;


                if(x_newmoon>=max_retry)

                    c_newmoon=3;

                else

                    delay(int_time);


                if(c_newmoon==1)

                    prints("^MNEWMOON OK");


                if(c_newmoon==2)

                    prints("^MNEWMOON canceled");

            }

        }

    }


    cputs_tr("ATdt*54*1048*2#^M");

    delay(70);

    cputs_tr("ath0^M");

    capture("*CLOSE*");     // 关闭CAPTURE文件

    usagelog("*CLOSE*");    // 关闭LOG文件

}


/////////////////////////////////////////////////////////////////

homepcug()

{

    int stat,t1,t2,t3,t4,t5,t6,t7,tt,tt2,t8,t9,t10;


    replyfile="..\BWAVE\UPLOAD\HOMEPCUG.NEW";


    initmodem();


    prints("^MDialing HOMEPCUG...");

    if(!dial("m07548469169",1))     // 拨号

        return 0;   // 如果没有CARRIER返回


    // 接通

    delay(50);      // 延时一秒,

    c_homepcug=2;


    cputc(27);    // 回车 -+

    delay(10);       //       +- 跳过DOOR

    cputc('^M');      // ESC  -+

    if(!waitfor2("<Esc>",10))    // 如果10秒钟之内

    {                                       // 没接到以上信息

        hangup();                           // 非正常退出

        return 0;

    }

    cputc(27); delay(5); cputc(27);     // 两次ESC


    t1=track("full name",1);

    t2=track("password",1);

    t3=track("dd-mm-yy",1);

    t4=track("y/n",1);

    t5=track("Enter",0);

    t6=track("回车",1);

    t7=track("min):",1);

    t8=track("ENTER",0);

    t9=track("yy-mm-dd",1);

    t10=track("mm-dd-yy",1);

    tt=curtime();

    tt2=curtime();


    while(1)

    {

        terminal();

        stat=track_hit(0);

        if(stat==t1)

        {

            cputs("Quarway Migh");  cputc('^M');    tt2=curtime();

        }

        if(stat==t2)

        {

            cputs("嘎咕");  cputc('^M');    tt2=curtime();

        }

        if(stat==t3)

        {

            cputs("26-11-73");  cputc('^M');    tt2=curtime();

        }

        if(stat==t9)

        {

            cputs("73-11-26");  cputc('^M');    tt2=curtime();

        }

        if(stat==10)

        {

            cputs("11-26-73");  cputc('^M');    tt2=curtime();

        }

        if(stat==t4)

        {

            cputc('n'); cputc('^M');    tt2=curtime();

        }

        if(stat==t5||stat==t6||stat==t8)

        {

            cputc('^M');    tt2=curtime();

        }

        if(stat==t7)    break;

        if(curtime()-tt>120)

        {

            track_free(0);

            hangup();

            return 0;

        }

        if(curtime()-tt2>10)

        {

            cputc('^M');    tt2=curtime();

        }

    }

    track_free(0);


    delay(10);

    cputc('m');cputc('^M');     // 到达主菜单,按M选择邮箱


    if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('w');cputc('^M');     // 邮箱菜单,按W选蓝波


    if(!bluewave()) return;


//    pcugup();


    if(!waitfor2("min):",20))    // 现在处于信箱菜单

    {

        hangup();

        return 0;

    }

    cputc('!');cputc('^M');     // 按G选择退出BBS


    if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('!');cputc('^M');     // 按G退出BBS

    delay(50);

    hangup();

    c_homepcug=1;   // PCUG登录过程正常完成

    delay(100);

}


/////////////////////////////////////////////////////////////////

// DATAFAST登录过程

// 请参考homepcug()里的注释

datafast()

{

    int i;

    int stat,t1,t2,t3,t4,t5,t6,t7,tt,tt2,t8,t9,t10;

    replyfile="..\BWAVE\UPLOAD\DATAFAST.NEW";


    initmodem();


    prints("^MDialing DATAFAST...");

    if(!dial("m07555423139",1))

        return 0;


    delay(50);

    c_datafast=2;


    cputc(27);

    delay(10);

    cputc('^M');

    if(!waitfor2("<Esc>",10))

    {

        hangup();

        return 0;

    }

    cputc(27); delay(5); cputc(27);


    t1=track("full name",1);

    t2=track("密码",1);

    t3=track("dd-mm-yy",1);

    t4=track("y/n",1);

    t5=track("Enter",0);

    t6=track("回车",1);

    t7=track("min):",1);

    t8=track("ENTER",0);

    t9=track("yy-mm-dd",1);

    t10=track("mm-dd-yy",1);

    tt=curtime();

    tt2=curtime();


    while(1)

    {

        terminal();

        stat=track_hit(0);

        if(stat==t1)

        {

            cputs("Quarway Migh");  cputc('^M');    tt2=curtime();

        }

        if(stat==t2)

        {

            cputs("嘎咕");  cputc('^M');    tt2=curtime();

        }

        if(stat==t3)

        {

            cputs("26-11-73");  cputc('^M');    tt2=curtime();

        }

        if(stat==t9)

        {

            cputs("73-11-26");  cputc('^M');    tt2=curtime();

        }

        if(stat==t10)

        {

            cputs("11-26-73");  cputc('^M');    tt2=curtime();

        }

        if(stat==t4)

        {

            cputc('n'); cputc('^M');    tt2=curtime();

        }

        if(stat==t5||stat==t6||stat==t8)

        {

            cputc('^M');    tt2=curtime();

        }

        if(stat==t7)    break;

        if(curtime()-tt>120)

        {

            track_free(0);

            hangup();

            return 0;

        }

        if(curtime()-tt2>10)

        {

            cputc('^M');

            tt2=curtime();

        }

    }

    track_free(0);


    delay(10);

    cputc('m');cputc('^M');


    if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('b');cputc('^M');


    if(!bluewave()) return;


    if(!waitfor2("min):",20))    // 现在处于信箱菜单

    {

        hangup();

        return 0;

    }

    cputc('g');cputc('^M');     // 按G选择退出BBS


    if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('g');cputc('^M');     // 按G退出BBS

    delay(50);

    hangup();

    c_datafast=1;

    delay(100);

}


/////////////////////////////////////////////////////////////////

// NEWMOON登录过程

// 参考homepcug()和datafast()的注释

newmoon()

{

    str buf[64];

    int stat,t1,t2,t3,t4,t5,t6,t7,tt,tt2,t8,t9,t10,t11,t12,t13;

    replyfile="..\BWAVE\UPLOAD\NEWMOON.NEW";


    initmodem();


    prints("^MDialing NEWMOON...");

    if(!dial("m0203847074",1))

    {

        delay(20);

        if(!dial("m0203198184",1))

            return 0;

    }


    delay(30);

    c_newmoon=2;


    cputc(27);

    delay(10);

    cputc('^M');

    if(!waitfor2("<Esc>",10))

    {

        hangup();

        return 0;

    }

    cputc(27); delay(5); cputc(27);


    t1=track("user ID",0);

    t2=track("密码",1);

    t3=track("dd-mm-yy",1);

    t4=track("y/n",1);

    t5=track("Enter",0);

    t6=track("回车",1);

    t7=track("min):",1);

    t8=track("ENTER",0);

    t9=track("yy-mm-dd",1);

    t10=track("mm-dd-yy",1);

    t11=track("y/n",1);

    t12=track("your name",1);

    t13=track("Password",1);

    tt=curtime();

    tt2=curtime();


    while(1)

    {

        terminal();

        stat=track_hit(0);

        if(stat==t1||stat==t12)

        {

            delay(5); cputs("Quarway Migh");  cputc('^M');    tt2=curtime();

        }

        if(stat==13||stat==t2)

        {

            delay(5); cputs("嘎咕");  cputc('^M');    tt2=curtime();

        }

        if(stat==t3)

        {

            cputs("26-11-73");  cputc('^M');    tt2=curtime();

        }

        if(stat==t9)

        {

            cputs("73-11-26");  cputc('^M');    tt2=curtime();

        }

        if(stat==t10)

        {

            cputs("11-26-73");  cputc('^M');    tt2=curtime();

        }

        if(stat==t4||stat==t11)

        {

            cputc('n'); cputc('^M');    tt2=curtime();

        }

        if(stat==t5||stat==t6||stat==t8)

        {

            cputc('^M');    tt2=curtime();

        }

        if(stat==t7)    break;

        if(curtime()-tt>120)

        {

            track_free(0);

            hangup();

            return 0;

        }

        if(curtime()-tt2>10)

        {

            cputc('^M');

            tt2=curtime();

        }

    }

    track_free(0);


    delay(10);

    cputc('m');cputc('^M');


    if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('w');cputc('^M');


    if(!bluewave()) return;


//    quotaup();

//    newmoonup();


    if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('!');cputc('^M');


    if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('!');cputc('^M');


    delay(50);

    hangup();

    c_newmoon=1;

    delay(100);

}


//////////////////////////////////////////////////////

// 计算当前是星期几

// 0 星期天, 1 星期一, 2 星期二, ...

dow()

{

    int i;

    i=(curtime()/86400)%7+4;

    if(i>6) i=i-7;

    return i;

}


///////////////////////////////////////////////////////

bluewave()

{

    int stat,t1,t2,t3,tt,tt2;

    str buf[64];


    if(!waitfor2("ENTER to continue...",30))

    {

        hangup();

        return 0;

    }

    cputc('^M');


    if(filefind(replyfile,0,buf)!=0)

    {

        if(!waitfor2("Select:",30))

        {

            hangup();

            return 0;

        }

        cputc('U');

        delay(10);

        send('Z',replyfile);

    }


    t1=track("[y,n,q]",1);

    t2=track("Main Menu",1);

    t3=track("T)ransfer",1);

    tt=curtime();

    tt2=curtime();


    while(1)

    {

        terminal();

        stat=track_hit(0);

        if(stat==t1)    // 提问如何响应FILE REQUEST

        {

            cputc('n');

            tt2=curtime();

        }

        if(stat==t2)    // 主菜单

            break;

        if(stat==t3)

        {

            cputc('t');

            tt2=curtime();

        }

        if(curtime()-tt>120)

        {

            track_free(0);

            hangup();

            return 0;

        }

        if(curtime()-tt2>10)

        {

            cputc('^M');

            tt2=curtime();

        }

    }


    track_free(0);

    cputc('D');


    if(!waitfor2("Please",120))

    {

        hangup();

        return 0;

    }

    cputc('^M');


    if(!waitfor2("Select:",120))

    {

        hangup();

        return 0;

    }

    cputc('^M');


    receive('Z',"");


    if(!waitfor2("Select:",120))

    {

        hangup();

        return 0;

    }

    cputc('Q');

    return 1;

}

//////////////////////////////////////////////////////////////////

initmodem()

{

    prints("^MInitializing...");

    cputs_tr("ATZ^M");   // 初始化MODEM,请修改为自己的初始字串

    delay(10);

    cputs_tr("ATF10^M");

    delay(10);

    cputs_tr("ATM1L3^M");

    delay(10);

    cputs_tr("ATS11=75^M");

    delay(10);

}

/////////////////////////////////////////////////////////////////

waitfor2(str waitstr,int time1)

{

    int wf1=0;


    while(1)

    {

        if(waitfor(waitstr,10))

            return 1;

        else

        {

            cputc('^M');

            wf1=wf1+1;

        }

        if(wf1>10)

            return 0;

    }

}

///////////////////////////////////////////////////////////////////

pcugup()

{

    if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('-');cputc('^M');


    if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('F');cputc('^M');


    if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('A');cputc('^M');


   if(!waitfor2("分组:",20))

    {

        hangup();

        return 0;

    }

    cputc('1');cputc('^M');


    if(!waitfor2("编号:",20))

    {

        hangup();

        return 0;

    }

    cputc('7');cputc('^M');


    if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('U');cputc('^M');


    if(!waitfor2("(S)",20))

    {

        hangup();

        return 0;

    }

    cputc('S');cputc('^M');

    send('Z',"..\temp\dogpstra.arj");


    if(!waitfor2("Enter",20))

    {

        hangup();

        return 0;

    }

    cputc('^M');


    if(!waitfor2(":",20))

    {

        hangup();

        return 0;

    }

    cputs("狗声演奏的<蓝色多瑙河>  :)");cputc('^M');cputc('^M');


    if(!waitfor2("选择:",20))

    {

        hangup();

        return 0;

    }

    cputc('s');cputc('^M');


    if(!waitfor2("Enter",20))

    {

        hangup();

        return 0;

    }

    cputc('^M');

}

////////////////////////////////////////////////////

newmoonup()

{

    if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('-');cputc('^M');

   if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('F');cputc('^M');

   if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('A');cputc('^M');

  if(!waitfor2("area:",20))

    {

        hangup();

        return 0;

    }

    cputs('10');cputc('^M');


    if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('U');cputc('^M');

   if(!waitfor2("(S)",20))

    {

        hangup();

        return 0;

    }

    cputc('S');cputc('^M');

    send('Z',"..\TEMP\dogpstra.arj");


    if(!waitfor2("Enter",20))

    {

        hangup();

        return 0;

    }

    cputc('^M');


    if(!waitfor2(":",20))

    {

        hangup();

        return 0;

    }

    cputs("狗声演奏的<蓝色的多瑙河>  :)");cputc('^M');

    cputc('^M');


    if(!waitfor2("选择:",20))

    {

        hangup();

        return 0;

    }

    cputc('s');cputc('^M');

    cputc('^M');

}

////////////////////////////////////////////////////

quotaup()

{

    str buf[20],fspec[]="..\TEMP\QUOT*.ARJ",buf2[64];


    if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('-');cputc('^M');

   if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('F');cputc('^M');

    if(!waitfor2("min):",20))

    {

        hangup();

        return 0;

    }

    cputc('A');cputc('^M');

    if(!waitfor2("area:",20))

    {

        hangup();

        return 0;

    }

    cputs('10');cputc('^M');


    while(filefind(fspec,0,buf)!=0)

    {

        buf2="..\TEMP\";

        strcat(buf2,buf);

        if(!waitfor2("min):",20))

        {

            hangup();

            return 0;

        }

        cputc('U');cputc('^M');

        if(!waitfor2("(S)",20))

        {

            hangup();

            return 0;

        }

        cputc('S');cputc('^M');

        send('Z',buf2);


        if(!waitfor2("Enter",20))

        {

            hangup();

            return 0;

        }

        cputc('^M');


        if(!waitfor2(":",20))

        {

            hangup();

            return 0;

        }

        cputs("深沪股市收市行情的.DBF文件 by Quarway Migh (日期参照文件名)");

        cputc('^M');

        cputc('^M');


        if(!waitfor2("选择:",20))

        {

            hangup();

            return 0;

        }

        cputc('s');cputc('^M');

        cputc('^M');

        fspec="";

        setchr(buf,0,'_');

        frename(buf2,buf);

        setchr(buf,0,'Q');

    }

}



--

        老顽童

※ 来源:.紫 丁 香 bbs.hit.edu.cn.[FROM: h51.hit.edu.cn]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:405.321毫秒