normal用户同一时间只能有一个登录session,如何实现多个登录?

本文详细介绍了如何使用Perl脚本结合BuildForge API进行项目身份验证、获取项目信息及长时间等待操作,并通过两个脚本(foreverToken.pl和shareToken.pl)实现项目的读取和共享。脚本演示了如何获取会话令牌、查找项目信息及在多个脚本间共享会话。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

声明:本博客只代表作者本人,不代表作者所在公司和组织等。如因此采用本博客内容造成的损失和不便,本博客概不负责。如需相应service请联系对应厂商


1,下载client

      

2,编写脚本

      脚本A(foreverToken.pl)

-----------------

#!/usr/bin/perl -w
use BuildForge::Services;

        $conn = new BuildForge::Services::Connection('localhost');
        $token = $conn->authUser('yq','qq');
        print "token: $token \n";
        #$conn->authToken($token);
 
        # Getting existing projects
        $project = BuildForge::Services::DBO::Project->findByName($conn, 'proj1');

        # Getter / setter functions
        $id = $project->getProjectId();
        $name = $project->getName();
        $class = $project->getBuildClass();
        $env = $project->getEnvironmentId();

        print "Name: $name \n";
        print "ID: $id \n";
        print "Class: $class \n";
        print "Env ID: $env \n";
        
        #wait for a very long, the other script can use the same session.
        my $verbose = 99999999;
        my $idx = 0;
        while ($idx<$verbose) {
         sleep 20;
         $idx =$idx+1;
         warn "index: $idx\n";
       }
                
        $conn->logout;
        $conn->close;

       脚本B(shareToken.pl

-------------------------

#!/usr/bin/perl -w
use BuildForge::Services;

        $conn = new BuildForge::Services::Connection('localhost');
        #$token = $conn->authUser('yq','qq');

        #get the token after the scriptA is executed
        $conn->authToken('77baef380c571000ca2b83f44d314d31');
 
        # Getting existing projects
        $project = BuildForge::Services::DBO::Project->findByName($conn, 'proj2share');

        # Getter / setter functions
        $id = $project->getProjectId();
        $name = $project->getName();
        $class = $project->getBuildClass();
        $env = $project->getEnvironmentId();

        print "Name: $name \n";
        print "ID: $id \n";
        print "Class: $class \n";
        print "Env ID: $env \n";
        
        
        #don't logout or close, for myabe other scripts are using this session at the same time
         print "exit";

3, 执行脚本

    如图1所示的目录结构

     perl -I "c:\\autofvt\rbf-services\lib" foreverToken.pl

     得到输出token,后修改shareToken.pl,然后在新的cmd窗口执行shareToken.pl

     perl -I "c:\\autofvt\rbf-services\lib" shareToken.pl


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值