<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    jojo's blog--快樂憂傷都與你同在
    為夢想而來,為自由而生。 性情若水,風(fēng)起水興,風(fēng)息水止,故時而激蕩,時又清平……
    posts - 11,  comments - 30,  trackbacks - 0
    Here is the script in it's
    entirety.
    It would be taylored to only execute one
    command not an open perl script. Better
    than having root .rhosts everywhere.
    I think where it does the:

    print F $Line;

    at the bottom is where I could put some
    kind of execute statement.
    Take the string and run it not print it
    to a file.



    socket.client.perl
    #!/usr/bin/perl
    #===============================================
    # Client -- using object interface
    # Support Windows and UNIX
    #===============================================
    use IO::Socket;
    my $sock = new IO::Socket::INET (
    PeerAddr => '128.166.11.13',
    PeerPort => '9999',
    Proto => 'tcp',
    );
    die "Could not create socket: $!"n" unless $sock;
    print $sock "Hi there!"n";
    $sock->send("Hi again!"n");

    close($sock);


    socket.server.perl
    #!/usr/bin/perl
    #===============================================
    # Server -- using object interface
    # Support Windows and UNIX
    #===============================================

    #use Proc::Daemon;
    use IO::Socket;
    #Proc::Daemon::Init();

    use POSIX qw(setsid);

    sub daemonize {
    die "Can't fork" unless defined (my $child = fork());
    exit 0 if $child;
    setsid();
    open(STDIN, "</dev/null");
    open(STDOUT, ">/dev/null");
    open(STDERR, ">&STDOUT");
    chdir '/';
    umask(0);
    #$ENV{PATH} = '/bin:/sbin:/usr/bin:/usr/sbin';
    return $$;
    };

    &daemonize;
    while() {
    my $new_sock = $sock->accept();

    ####################################
    # Put a message to file. #
    ####################################

    while(defined($Line = <$new_sock>)) {
    open (F,"+>>/lhome/root/testfile.txt");
    print F $Line;
    close F;
    };
    close($sock);
    }; #End of while cycle
    A. Clay Stephenson Expert in this area This member has accumulated 80000 or more points     
    May 21, 2004 16:47:45 GMT  10 pts     
    In that case, $Line has your input so you can use it to execute whatever you like.

    Typically, your client should send a formatted request string of some type. I like to use <tabs> to separate the fields and then your server responds each time it sees a new line of input.



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

    All I am saying in that any client/server architecture, you must establish some sort of protocol.

    Let's suppose that your server does 4 things:
    1) lists files in a dedicated directories
    2) removes 1 file
    3) add's a line to an existing file
    4) kill the server

    Your create client requests that adhere to this, for example, you formant your protocol like this
    request_code<tab>string1<tab>string2<LF>

    Now every line sent to the server expects these 3 arguments -- although some may simply be dummy args. Tabs are nice because unlike spaces or colons or commas they are not typically part of strings. Typically the request_code is something very easy to parse; e.g 1 - list; 2 - remove, 4 - kill,kill,kill

    If you wanrt to see some examples of this along with a little explanation, go to www.sysadminmag.com and look under the April '03 issue. I wrote an article that used Perl a Perl client/server pair to implement multi-host semaphores. Their web page also has a source code link where you will find the client and server pieces.

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

    For now though. I just wanted something
    simple to get around the root .rhosts problem. I was thinking as a security measure
    of passing a code to the server.pl but don't
    know the perl syntax at this time.
    Could you show me the simple syntax for
    passing two args.

    e.g.

    From client.pl send:

    1234 shutdown.sh

    On server.pl check code then run command:

    1234 shutdown.sh


    On my client.perl I currently have:

    print $sock "shutdown.sh"

    On my server.perl I have:

    while(defined($Line = <$new_sock>)) {
    system($Line);
    close($sock);
    }; #End

    posted on 2009-08-06 12:11 Blog of JoJo 閱讀(292) 評論(0)  編輯  收藏 所屬分類: 每日一記My Script

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿(6)

    隨筆檔案

    文章分類

    文章檔案

    新聞分類

    新聞檔案

    相冊

    收藏夾

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 夜夜亚洲天天久久| 久久精品无码一区二区三区免费| 成人性生活免费视频| 久久国产亚洲精品麻豆| A级毛片成人网站免费看| 免费人成视频在线观看不卡| 亚洲性无码AV中文字幕| 亚洲黄色免费电影| 亚洲香蕉免费有线视频| 日本黄色动图免费在线观看| 亚洲五月综合缴情在线观看| 一级毛片一级毛片免费毛片| 亚洲成AⅤ人影院在线观看| 午夜亚洲国产精品福利| 国产视频精品免费| 国产精品亚洲AV三区| 国产真实伦在线视频免费观看| 亚洲高清一区二区三区电影| 最近中文字幕无吗免费高清| 精品亚洲国产成人| 毛片免费观看网址| MM1313亚洲国产精品| 国产乱子影视频上线免费观看| 老司机亚洲精品影院在线观看| 波多野结衣中文一区二区免费| 日韩欧美亚洲国产精品字幕久久久 | 国产va免费精品| 亚洲伊人色欲综合网| 最近2019中文免费字幕在线观看| 亚洲成AV人在线观看天堂无码| 日韩免费的视频在线观看香蕉| 久久久久亚洲精品成人网小说| 久久99国产乱子伦精品免费| 亚洲第一页在线播放| 中文字幕无码视频手机免费看| 天天爽亚洲中文字幕| 亚洲精品成人片在线观看| 国产综合免费精品久久久| 国内自产拍自a免费毛片| 另类图片亚洲校园小说区| 久久久亚洲精品无码|