<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)

    隨筆檔案

    文章分類

    文章檔案

    新聞分類

    新聞檔案

    相冊

    收藏夾

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲国产婷婷香蕉久久久久久| 国产免费av片在线看| 性做久久久久免费看| 亚洲人成图片网站| 最近免费中文字幕视频高清在线看 | 亚洲精品岛国片在线观看| 亚洲精品无码av片| 在线观看国产情趣免费视频| 亚洲一级黄色大片| 在线jlzzjlzz免费播放| 美女18一级毛片免费看| 亚洲成A人片在线观看无码3D| 国产精品免费大片一区二区| 亚洲熟妇无码AV在线播放| 一个人免费日韩不卡视频| 亚洲国产综合在线| 最好免费观看韩国+日本| 国产精品亚洲а∨无码播放麻豆| 亚洲精品国产高清不卡在线| 国产精品成人69XXX免费视频| 亚洲乱码无码永久不卡在线| 特级精品毛片免费观看| 亚洲日本久久久午夜精品| 国产美女无遮挡免费视频网站| 四虎国产精品成人免费久久| 中国亚洲女人69内射少妇| 最近2018中文字幕免费视频| 在线综合亚洲中文精品| 亚洲成?Ⅴ人在线观看无码| 久久免费视频网站| 亚洲嫩草影院在线观看| 免费欧洲毛片A级视频无风险| 国产又黄又爽胸又大免费视频| 91亚洲精品视频| 四虎影库久免费视频| 一级毛片免费观看不卡的| 亚洲国产成人99精品激情在线| 亚洲成A∨人片天堂网无码| 最近免费中文字幕高清大全 | 久久青草免费91观看| 久久久久亚洲精品无码网址色欲|