shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Traduzir script para shell


From: Reinaldo Almeida Bonilho
Subject: Traduzir script para shell
Date: Mon, 25 Dec 2006 17:27:37 -0300

Bom Dia PessoALL,

Ja perdi um tempão tentando traduzir um script PHP para ShellScript,
porem, sem sucesso.

Alguem na lista pode me ajudar, o script transmite um arquivo texto
via http, vide código abaixo:

==> Inicio código
<?
        header('Content-type: txt');

        // Path local do arquivo com as mensagens
        $file_path = "file_test.txt"; // << Esse path deve ser modificado

        // String com conteúdo do arquivo para envio pela URL
        $file_content = "";

        // Abre o arquivo
        $handle = fopen($file_path, "r");
        while (!feof ($handle)) {
                //$msg_total = $msg_total + 1;
                $line = fgets($handle, 4096);
                $line = str_replace('\r','',$line);
                $file_content .= $line;
        }
        fclose($handle);


        // Prepara os dados para HTTP POST
        $postdata .= "list=".$file_content;

        $host = "system.human.com.br";

        $uri = "/upload_sms.php";

        $da = fsockopen($host, 80, $errno, $errstr);

        if (!$da && $errno != 0) {
           echo "$errstr ($errno)<br/>\n";
           echo $da;
        } else {
                $output ="POST $uri  HTTP/1.0\r\n";
                $output.="Host: $host\r\n";
                $output.="User-Agent: PHP Script\r\n";
                $output.="Content-Type: application/x-www-form-urlencoded;
charset=ISO-8859-1\r\n";
                $output.="Content-Length: ".strlen($postdata)."\r\n";
                $output.="Connection: close\r\n\r\n";
                $output.=$postdata;
                fwrite($da, $output);
                while (!feof($da)) $response.=fgets($da, 128);
                $response=split("\r\n\r\n",$response);
                $header=$response[0];
                $responsecontent=$response[1];
                if(!(strpos($header,"Transfer-Encoding: chunked")===false)){
                        $aux=split("\r\n",$responsecontent);
                        for($i=0;$i<count($aux);$i++)
                        if($i==0 || ($i%2==0))
                           $aux[$i]="";
                        $responsecontent=implode("",$aux);
                } //if
                echo chop($responsecontent);
        } //else


?>

==> Fim código

Muito Obrigado,

Reinaldo de A. Bonilho


reply via email to

[Prev in Thread] Current Thread [Next in Thread]