home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / COMET.ZIP / SAMPLE.CMT < prev   
Text File  |  1991-09-27  |  16KB  |  603 lines

  1. #  Same COMET script file
  2. #  View COMET13.INF file for details on creating a COMET script file.
  3.  
  4. comet display_on;
  5. comet debug_on srpi;
  6.  
  7.  
  8. @define LOOP_COUNT 30;
  9. @define NO_OF_DATA_SENDS 1;
  10. @define NO_OF_DATAGRAM_SENDS 1;
  11. @define NO_OF_FILE_SENDS 1;
  12. @define CALL_TIMEOUT 5;           # Call timeout in minutes
  13. @define LENGTH 30;           # Length of test case in minutes.
  14. #define SEND_FILENAME     test.txt;
  15. #define COMPARE_FILENAME  test2.txt;
  16. @define PC1 pc1;
  17. @define PC2 pc2;
  18. @define RECV_TIMEOUT 0;           # Recv timeout in seconds (0 = no timeout)
  19. @define SEND_TIMEOUT 0;           # Send timeout in seconds (0 = no timeout)
  20. @define groupname groupname;
  21. @define VM1USER VM1USER;
  22. @define VM1PSW VM1PSW;
  23. @define AS4PSW AS4PSW;
  24. @define AS4USER AS4USER;
  25. @define NODE_ADDR1 NODE_ADDR1;
  26.  
  27. @define D_B "this is a test line. one two three four five six seven eight.
  28.              the quick brown fox jumped over the lazy dog.
  29.              this is a test line. one two three four five six seven eight.
  30.              the quick brown fox jumped over the lazy dog.
  31.              this is a test line. one two three four five six seven eight.
  32.              the quick brown fox jumped over the lazy dog.
  33.              this is a test line. one two three four five six seven eight.
  34.              the quick brown fox jumped over the lazy dog.";
  35.  
  36.  
  37. #  ACDI Calls
  38. #
  39. # Opem COM1 port and set ASYNCH Line Speed.
  40. #
  41. #------------------------------------------------------------------------
  42.  
  43. acdi open dev=com1;
  44.  
  45. acdi setbit send=1200, rcv=1200;
  46.  
  47. acdi setlinectrl stopbits=1,
  48.              parity=none,
  49.              databits=8;
  50.  
  51. #/*****************************************************************
  52. #
  53. # Start APPC and Autostart COMET on PC 2 and PC 3.
  54. #
  55. #------------------------------------------------------------------------
  56.  
  57. appc tp_started local_lu = "SENDER",
  58.                 tp       = "COMET.AUTOSTART",
  59.                 prc=x'0';
  60.  
  61.  
  62.  
  63. appc mc_alloc conv=1,
  64.             remote_lu="RECEIVR2",
  65.             mode="MODE1",
  66.             tp="COMET.AUTOSTART",
  67.             sync=confirm,
  68.             prc=x'0';
  69.  
  70. appc mc_alloc conv=2,
  71.             remote_lu="RECEIVR3",
  72.             mode="MODE1",
  73.             tp="COMET.AUTOSTART",
  74.             sync=confirm,
  75.             prc=x'0';
  76.  
  77.  
  78. #/***********************************************************************
  79. #
  80. # Database Creation and Granting Authority.
  81. #
  82. #------------------------------------------------------------------------
  83.  
  84. #
  85. # Create database METMA02
  86. #
  87. DBM CREATE_DB DB=METMA02;
  88. DBM START_USING_DB DB=METMA02, USE=s, RC=0;
  89. #
  90. # Create a table and insert values
  91. #
  92. SQL "CREATE TABLE testtab
  93.          (name VARCHAR(10),
  94.           dept SMALLINT)";
  95. SQL "INSERT INTO testtab(name, dept) VALUES('Leroy',644)";
  96. SQL "INSERT INTO testtab (name, dept) VALUES ('Art', 644)";
  97. SQL "INSERT INTO testtab (name, dept) VALUES ('Brad',644)";
  98. SQL "INSERT INTO testtab (name, dept) VALUES ('John',644)";
  99. SQL "INSERT INTO testtab (name, dept) VALUES('Derek',644)";
  100. SQL "INSERT INTO testtab (name, dept) VALUES ('Dan',644)";
  101. SQL "INSERT INTO testtab (name, dept) VALUES ('Jim',644)";
  102. SQL "INSERT INTO testtab (name, dept) VALUES('Chuck',644)";
  103. SQL "INSERT INTO testtab (name, dept) VALUES('Mike', 644)";
  104. SQL "INSERT INTO testtab (name, dept) VALUES('Jeff', 644)";
  105.  
  106. SQL "GRANT dbadm ON DATABASE TO metMA222";
  107. SQL "GRANT dbadm ON DATABASE TO metMA223";
  108. SQL "GRANT all ON TABLE testtab TO public";
  109.  
  110. SQL "COMMIT";
  111.  
  112. appc mc_confirm conv=1;
  113. appc mc_confirm conv=2;
  114.  
  115. #***********************************************************************
  116. #
  117. # Begin Scenario MA02 Main Loop.
  118. #
  119. #------------------------------------------------------------------------
  120.  
  121.  
  122. begin_loop loop1 count=LOOP_COUNT;         # Main loop for PC1
  123.  
  124.     OS2_SHELL "MA02REX";
  125.  
  126.     os2_shell "echo Issuing FIRST SRPI call";
  127.  
  128.     OS2_API DOSBEEP 200,500;
  129.  
  130. #   comet debug_on srpi;
  131.  
  132.     srpi sendreq function=x'0000',
  133.              data="0987654321",
  134.              parm="12345678",
  135.              server="SRPIEM31",
  136.              rcsrpi=x'00000000',
  137.              rcsrvr=x'0000000',
  138.              rparm="12345678",
  139.              rdata="0987654321";
  140.  
  141.  
  142.     os2_shell "echo Issuing NEXT SRPI call";
  143.  
  144. # Verify that we are still connected to VM.
  145.  
  146.     OS2_API DOSBEEP 200,500;
  147.     OS2_API DOSBEEP 200,500;
  148.  
  149.     srpi sendreq server="SRPIEM31",
  150.              function = x'0000',
  151.              parm="c:\MET12\common\parm.req",
  152.              data="c:\MET12\common\data.req",
  153.              rcsrpi=x'00000000',
  154.              rcsrvr=x'00000000',
  155.              rparm="c:\MET12\common\parm.req",
  156.              rdata="c:\MET12\common\data.req";
  157.  
  158.    os2_shell "dir c:\MET12\common\*.r";
  159.    os2_shell "type c:\MET12\common\parm.r";
  160.    os2_shell "type c:\MET12\common\data.r";
  161.  
  162.     #************************************************************************
  163.     #
  164.     # APPC Communications
  165.     OS2_API DOSBEEP 600,500;
  166.     #
  167.     #------------------------------------------------------------------------
  168.  
  169.     appc mc_send_data conv=1,data="hi there";
  170.  
  171.     appc mc_confirm conv=1;
  172.  
  173.     appc mc_send_data conv=2,data="hi there";
  174.  
  175.     appc mc_confirm conv=2;
  176.  
  177.     appc mc_send_data conv=1,data ="This is another test\
  178.            one, two, three";
  179.  
  180.     appc mc_confirm conv=1;
  181.  
  182.     appc mc_send_data conv=2,data ="This is another test\
  183.            one, two, three";
  184.  
  185.     appc mc_confirm conv=2;
  186.  
  187.     os2_api dossleep seconds=15;
  188.  
  189.  
  190.     appc mc_send_data conv=2, file=C:\MET12\COMMON\small.doc;
  191.  
  192.     appc mc_confirm conv=2;
  193.  
  194.     appc mc_rcv_wait conv=2, crc=C:\MET12\COMMON\small.doc;         # check CRC
  195.  
  196.     appc mc_rcv_wait conv=2, what=CONF;
  197.  
  198.     appc mc_confirmed conv=2;
  199.  
  200.  
  201. #************************************************************************
  202. #   Begin LAN Server/Requester Section
  203. #     Make a mailslot on Requester 1
  204.  
  205.     lan make_mailslot name=\mailslot\SRVN, #Make the server mailslot
  206.         msgsize=24000,
  207.         slotsize=24000;
  208.  
  209.     lan mailslot_info name=\mailslot\SRVN,
  210.         outfile=SRVN.TXT;
  211.  
  212.     lan write_mailslot name=\\metMA222\mailslot\REQ1N,  # Write to SL32U1
  213.         message=D_B2,
  214.         priority=8,  # 9 is the highest
  215.         class = 2,
  216.         timeout=1800000; # milliseconds
  217.  
  218.     lan read_mailslot name=\mailslot\SRVN, # REQ1 just wrote
  219.         timeout=-1,
  220.         outfile=REQ1.txt;
  221.  
  222.  
  223.     lan write_mailslot name=\\metMA223\mailslot\REQ2N,  # SL32U2 mailslot
  224.         message=D_B2,
  225.         priority=8,  # 9 is the highest
  226.         class = 2,
  227.         timeout=-1; # milliseconds
  228.  
  229.     lan read_mailslot name=\mailslot\SRVN, # REQ2 just wrote
  230.         timeout=-1,
  231.         outfile=REQ2.txt;
  232.  
  233.     lan delete_mailslot name=\mailslot\SRVN; #Delete the server mailslot
  234.  
  235. #
  236. #   End LAN Server/Requester Section
  237. #************************************************************************
  238.  
  239.     #************************************************************************
  240.     #
  241.     # Start ACDI Communications
  242.     OS2_API DOSBEEP 800,500;
  243.     #
  244.     #------------------------------------------------------------------------
  245.  
  246.     comet debug_on acdi;
  247.  
  248.  
  249.     #
  250.     # Send a file to a secondary PC using ACDI
  251.     acdi connect type=4,
  252.               timeout1=0,
  253.               timeout2=1000,
  254.               prefix=" ",
  255.               suffix=" ",
  256.               number=" ";
  257.  
  258.     os2_api dossleep seconds=5;
  259.  
  260.     acdi send data="Hello There";
  261.  
  262.     acdi rcv data="How are you?";
  263.  
  264.     os2_api dossleep seconds=10;
  265.  
  266.     acdi send file=C:\met12\common\logo.exe, timeout=1400;
  267.  
  268.  
  269.     acdi rcv file=C:\met12\common\logt.EXE, timeout=1000;
  270.  
  271.     comet compare_files file1=c:\met12\common\logo.exe,
  272.                     file2=c:\met12\common\logt.exe;
  273.  
  274.     OS2_SHELL "Echo The received IBM logo will now be displayed";
  275.  
  276.     OS2_SHELL "c:\met12\common\logt.exe";
  277.  
  278.     #comet debug_off acdi;
  279.  
  280.  
  281.     os2_shell "echo Next: Disconnect";
  282.     acdi disconnect;
  283.  
  284.     #/***********************************************************************
  285.     #
  286.     # 802.2 and NetBios Communication with PC 2.
  287.     OS2_API DOSBEEP 1000,500;
  288.     #
  289.     #------------------------------------------------------------------------
  290.  
  291.     os2_shell "echo Opening adapter 0";
  292.  
  293.     :d_open_a
  294.     802.2 dir_open_adapter open_options=x'2100', adapter=0;
  295.  
  296.  
  297.     :d_status
  298.     802.2 dir_status adapter=0;
  299.  
  300.     :d_open_sap1
  301.     802.2 dlc_open_sap adapter=0,
  302.       sap=8,
  303.       station_count=1;                    # Line added by Art B 11/17
  304.  
  305.     :d_open_station
  306.     802.2 dlc_open_station adapter=0,
  307.       sap=8,
  308.       station=2,
  309.       rsap=8,
  310.       dest_node_addr=x'4000AC305202',
  311.       rc=x'00';
  312.  
  313.  
  314.     :d_status2
  315.     802.2 dir_status adapter=0;
  316.  
  317.     :d_open_sap3
  318.     802.2 dlc_open_sap adapter=0,
  319.     sap=10,
  320.     station_count=1;                    # Line added by Art B 11/17
  321.  
  322.     os2_shell "echo Issuing read command for Sap = 2";
  323.  
  324.     :d_status3
  325.     802.2 dir_status adapter=0;
  326.  
  327.    os2_api dossleep seconds=20;
  328.  
  329.     :d_connect
  330.     802.2 dlc_connect_station sap=8,
  331.       station=2;
  332.  
  333.     802.2 receive adapter=0,
  334.       sap=8,
  335.       station=2,
  336.       rc=x'ff';    #command in progress
  337.  
  338.     comet msg msg="About ready to transmit I-frame";
  339.  
  340.     802.2 transmit_i_frame adapter=0,
  341.           sap=8,
  342.           station=2,
  343.   data="This is a receive that the sending side is issuing. Communications";
  344.  
  345.     802.2 read adapter=0,
  346.       sap=8,
  347.       station=2,
  348.       event_set=RECEIVE,      # bit 2 is RECEIVE notification
  349.       data="Hello, Arthur.";
  350.  
  351.  
  352.     802.2 receive_cancel adapter=0,
  353.       sap=8,
  354.       station=2,
  355.       rc=x'00';
  356.  
  357.     :d_close_station
  358.     802.2 dlc_close_station adapter=0,
  359.       sap=8,
  360.       station=2,
  361.       rc=x'00';
  362.  
  363.     :d_status4
  364.     802.2 dir_status adapter=0;
  365.  
  366.     :d_close_sap
  367.     802.2 dlc_close_sap adapter=0,
  368.       sap=8;
  369.  
  370.     :d_close_sap2
  371.     802.2 dlc_close_sap adapter=0,
  372.       sap=10;
  373.  
  374.     os2_shell "echo That's it for 802.2 folks...";
  375.  
  376. #----------------------------------------------------
  377.  
  378. comet debug_on netbios;
  379.  
  380. :pc1
  381.    comet debug_on netbios;
  382. #   netbios reset;
  383.     netbios reset sessions=2, commands=4, names=10;
  384.  
  385. comet debug_off netbios;
  386.  
  387.     netbios add_name_wait name=METPC1;
  388.  
  389.        call call_pc2;
  390.  
  391.        call send_data_test;                   # send a bunch of data..
  392.  
  393.    os2_api dossleep seconds=10;
  394.  
  395.        call send_datagrams_to_pc2;
  396.  
  397.    os2_api dossleep seconds=10;
  398.  
  399.  
  400.  
  401.        netbios session_status name=*;         # get session status for all names
  402.  
  403. # This will eventually be used with B/L
  404.  
  405.        netbios status call_name=METPC1,
  406.                       file=c:\met12\comet\netb.lst,
  407.                       display;
  408.  
  409.  
  410.  
  411.        :add_name_test1
  412.  
  413.            netbios add_name name=a1;
  414.            netbios add_name name=b1;
  415.            netbios add_name name=c1;
  416.            netbios add_name name=d1;
  417.            netbios add_name name=e1;
  418.            netbios add_name name=f1;
  419.            netbios add_name name=g1;
  420.  
  421.            netbios delete_name name=a1;
  422.            netbios delete_name name=b1;
  423.            netbios delete_name name=c1;
  424.            netbios delete_name name=d1;
  425.            netbios delete_name name=e1;
  426.            netbios delete_name name=f1;
  427.            netbios delete_name name=g1;
  428.  
  429.         call send_file_test;
  430.  
  431.  
  432.         call receive_data_test;                # ... then receive a bunch...
  433.         call receive_file_test;
  434.  
  435.     call hang_up_session1;
  436.  
  437.     os2_api dossleep seconds=5;
  438.  
  439.  
  440.     netbios delete_name name=METPC1;
  441.  
  442. #   netbios reset free_all = yes;
  443.     netbios reset sessions=2, commands=4, names=10, free_all=yes;
  444.  
  445.     802.2 dir_close_adapter adapter=0;
  446.  
  447.  
  448. #   appc mc_rcv_wait conv=1, what=SEND;
  449.     appc mc_rcv_wait conv=2, what=SEND;
  450.  
  451.  
  452. #/***********************************************************************
  453. #
  454. # Local Database SQL commands
  455. #
  456. #------------------------------------------------------------------------
  457.  
  458.  
  459. sql "select * from testtab where dept=644", file=dept644.out;
  460.  
  461. sql "select * from testtab where dept=44", file=dept44.out;
  462.  
  463. sql "commit";
  464.  
  465. comet compare_files file1=dept644.out, file2=c:\met12\comet\dept644.vfy;
  466. comet compare_files file1=dept44.out, file2=c:\met12\comet\dept44.vfy;
  467.  
  468.  
  469.  
  470.     #/***********************************************************************
  471.     #
  472.     # End Scenario MA02 Main Loop.
  473.     #
  474.     #------------------------------------------------------------------------
  475.  
  476.     end_loop loop1;
  477.  
  478. #
  479. # APPC DeAllocate
  480. #
  481. #------------------------------------------------------------------------
  482.  
  483.     appc mc_dealloc conv=1;
  484.     appc mc_dealloc conv=2;
  485.  
  486. #************************************************************************
  487. #
  488. # Stop Using Db and Drop Db.
  489. #
  490. #------------------------------------------------------------------------
  491.  
  492. os2_api dossleep seconds=60;
  493. dbm stop_using_db;
  494. dbm drop_db DB=METMA02;
  495.  
  496. #************************************************************************
  497. #
  498. # EXIT COMET.
  499. #
  500. #------------------------------------------------------------------------
  501.  
  502. comet exit;
  503.  
  504. # ---------------------------------------------------------------------
  505. #          Subroutines
  506. # ---------------------------------------------------------------------
  507. :send_datagrams_to_pc2
  508.  
  509.     begin_loop send_loop count=NO_OF_DATAGRAM_SENDS;
  510.       netbios send_datagram name=METPC1, call_name=METPC2, data=D_B;
  511.     end_loop send_loop;
  512.     return;
  513.  
  514. :do_a_return            # delete will take place when hang_up completes
  515.     return;
  516.  
  517. :receive_datagrams_from_pc2
  518.  
  519.     begin_loop rcv_loop count=NO_OF_DATAGRAM_SENDS;
  520.       netbios recv_datagram name=METPC1, data=D_B;
  521.     end_loop rcv_loop;
  522.     return;
  523.  
  524. # ---------------------------------------------------------------------
  525. :hang_up_temp_session
  526.     netbios hang_up session=TEMP_SESSION_NUM;
  527.  
  528.     # Test to see if we get a 'Session_Closed' status.  If we do that
  529.     #   means that the other side has already done a Hang_Up.
  530.     if netb_rc = x'0a' clear netb_rc;
  531.     return;
  532.  
  533. :l1
  534. begin_loop test count=10, time=1;
  535.   os2_shell "echo infinite loop!";
  536.   os2_shell "echo testing!";
  537. end_loop test;
  538. :test
  539.  
  540. # ---------------------------------------------------------------------
  541. :call_pc2
  542.  
  543.     # Keep issuing CALLs until we get a LISTEN.
  544.  
  545.     begin_loop do_call time=CALL_TIMEOUT;
  546.         netbios call_wait name=METPC1, call_name=METPC2, session=1,
  547.                           rcv_timeout=RECV_TIMEOUT, snd_timeout=SEND_TIMEOUT;
  548.         if netb_rc = x'00' break_to have_call;
  549.         clear netb_rc;
  550.     end_loop do_call;
  551.  
  552.     os2_shell "echo No listen found!";
  553.     comet exit errorlevel=1;
  554.  
  555.     :have_call
  556.     return;
  557.  
  558. # ---------------------------------------------------------------------
  559. # SEND/RECEIVE test
  560. # ---------------------------------------------------------------------
  561. :send_data_test
  562.     begin_loop send_loop count=NO_OF_DATA_SENDS;
  563.       netbios send session=1, data=D_B;
  564.     end_loop send_loop;
  565.     return;
  566.  
  567. :receive_data_test
  568.     begin_loop rcv_loop count=NO_OF_DATA_SENDS;
  569.       netbios recv session=1, data=D_B;
  570.     end_loop rcv_loop;
  571.     return;
  572. # ---------------------------------------------------------------------
  573. # SEND/RECEIVE file test
  574. # ---------------------------------------------------------------------
  575. :send_file_test
  576.     begin_loop send_loop count=1;
  577.       netbios send session=1, file=c:\met12\common\data.req;
  578.       # w/ databse file=ma02p1.out;
  579.  
  580. #THE FILE COMPARISON WILL BE DONE LOCALLY
  581. # By Art B  comet compare_files file1=ma02p1.out, file2=ma02px.out;
  582.     end_loop send_loop;
  583.     return;
  584.  
  585. :receive_file_test
  586.     begin_loop rcv_loop count=1;
  587.       netbios recv session=1, file=data.rcv;   # w/ db file=ma02py.out;
  588.       comet compare_files file1=data.rcv, file2=c:\met12\common\data.req;
  589.     # comet compare_files file1=ma02p1.out, file2=ma02py.out;
  590.     end_loop rcv_loop;
  591.     return;
  592.  
  593. # ---------------------------------------------------------------------
  594. :hang_up_session1
  595.     netbios hang_up session=1;
  596.  
  597.     # Test to see if we get a 'Session_Closed' status.  If we do that
  598.     #   means that the other side has already done a Hang_Up.
  599.     if netb_rc = x'0a' clear netb_rc;
  600.     return;
  601. # ---------------------------------------------------------------------
  602.  
  603.