Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 27
  1. #1

    variabile esterna generata da php ad uno script perl

    Come faccio a passare una variabile esterna generata da un'API php ad uno script perl?

    Mi spiego: uno script php mi restituisce l' uid dell'utente che si logga nella variabile $userid (se ad esempio ho tre utenti definiti, allora $userid puo' assumere i valori 1, 2, 3.)

    Ho un script perl che richiama un suo file di config, così:
    my($configfile)="$bbhome/www/sla.cfg";

    Se io però sostituisco sla.cfg con tre file: 1.cfg, 2.cfg, 3.cfg, uno cioè per ogni utente, come devo modificare il perl affinchè vada a prendersi il giusto file a seconda del valore assunto dalla variabile $userid?
    Vi prego aiutatemi, allo stato delle mie conoscenze, è per me un problemone!!!!

    Grazie a tutti

  2. #2
    Prima chiarisci come viene invocato lo script perl a cui devi passare la variabile, poi vediamo il metodo che dipende da questo.
    Marco Allegretti
    shishii@tiscalinet.it
    Lang: PERL, PHP, SQL.
    Linux user n° 268623 Fedora Core 10, Fedora Core 6, Debian Sarge on mips

  3. #3
    Viene invocato via cgi, cioè /cgi-bin/sla-report.pl
    Almeno credo sia questo che mi hai chiesto...scusa l'ignoranza ma sono un neofita

    Grazie tante

  4. #4
    Non mi sono spiegato.

    Come fai a passare dagli script php al CGI?

    lo richiami tramite un form?
    tramite un URL?
    tramite una funzione system?
    come immagine?
    Marco Allegretti
    shishii@tiscalinet.it
    Lang: PERL, PHP, SQL.
    Linux user n° 268623 Fedora Core 10, Fedora Core 6, Debian Sarge on mips

  5. #5
    nello script php richiamo quello perl con l'istruzione:

    echo "Clicca qui";

    dal mio portale gestito con MDPRO (tipo PHPNUKE)utilizzo inoltre il modulo postwrap per caricare documenti html, perl etc all' interno delle pagine php

  6. #6
    aleluia ....

    allora...

    è sufficiente che tu passi il nome e il contenuto della variabile tramite il link che crea echo, in questo modo:

    Clicca qui

    e poi nello script Perl la raccogli.
    Marco Allegretti
    shishii@tiscalinet.it
    Lang: PERL, PHP, SQL.
    Linux user n° 268623 Fedora Core 10, Fedora Core 6, Debian Sarge on mips

  7. #7
    Innanzitutto ti ringrazio per il tuo aiuto e perchè hai gentilmente sopportato la mia ignoranza....

    per lo script php il problema era piu chiaro, ora grazie a te lo è ancora di piu'...ma le maggiori difficoltà riguardano proprio come raccogliere la var in perl...infatti il prog originale definisceç
    my($configfile)="$bbhome/.../sla-report.cfg";

    ora invece dovrei avere una cosa del genere:
    my($configfile)="$bbhome/.../$userid.cfg";
    dove userid puo' essere = a 3 0 a 4(uid dei miei utenti)
    e quindi lo script deve poter caricare o 3.cfg o 4.cfg

    Ora a parte un dubbio di sintassi nell'istruzione precedente, credo che devo anche modificare il codice per consentire questo passaggio di un nuovo argomento ($userid)allo script, mi sbaglio?

    SOS,please

  8. #8
    Ti invio il codice per maggiore chiarezza...

    #!/usr/bin/perl -w

    # sla-report.pl
    #
    use strict;
    use Time::Local;


    # -----------------------------------------------------------------------------
    #
    # C O N F I G U R A B L E V A R I A B L E S
    #
    # -----------------------------------------------------------------------------

    # Where the BBHOME is
    # ---------------------------------------------------
    my($bbhome) = "/usr/local/bb";

    # Where to find the history logs to analyze (normally
    # found in your bbvar/hist-directory)
    # ---------------------------------------------------
    my($histdir) = "/usr/local/bbvar/hist";

    # Where to get history external to Big Brother
    # This would include outages that were not caught by
    # big brother, or maintenance enable/disables that
    # weren't sent to bigbrother in time
    my($exthistfile) = "/usr/local/bbvar/ext/sla-report/history.txt";

    # The name of your configfile
    # ---------------------------
    my($configfile) = "$bbhome/ext/sla-report/sla-report.cfg";

    # Web-stuff
    # ---------
    my($webdir) = "$bbhome/web";
    my($webheader) = $webdir . "/bb_header";
    my($webfooter) = $webdir . "/bb_footer";

    # Data structures
    # %apps will contain the break down of applications from the config file:
    # $apps{GROUPNAME}->{COMPONENTS}->{COMPONENTNAME}->{HOSTS}->(array of hosts)
    # {TESTS}->(array of tests)
    # {TESTINFO}->{TESTNAMES host.test format}->{STATUS} known test
    # {TOTAL_GREEN} Actual uptime of test
    # {SW}->(array of service windows)
    # {DEPENDS}->(array of dependencies)
    # {TYPE}->[USER|SYSTEM|CORE]
    # {TOTAL_TIME} = Total of expected uptime of component
    # {TOTAL_GREEN}= Total of actual uptime of component
    # {TOTAL_TIME} = Total of expected uptimes of each USER component
    # {TOTAL_GREEN}= Total of actual uptime of each USER component
    my(%apps);

    # %components_by_test will be a reverse lookup of test (hostname.test format)
    # to an array of ($apps{GROUPNAME}->{COMPONENTNAME}, GROUPNAME, COMPONENTNAME)
    my(%components_by_test);

    # %events_by_app will be a hash of arrays. Linking appname to a list of
    # all events (including servicewindow events)
    my(%events_by_app);

    # %ext_events_by_test will be a hash keyed by test of all the events from an external
    # history file
    my(%ext_events_by_test);

    my($debug)=0;

    # cgi is set to 1 if this script was called from a web server
    my($cgi)=0;

    # -----------------------------------------------------------------------------

    my($query);
    if ( $ENV{'SERVER_SOFTWARE'} ) {
    $cgi = 1;
    use CGI;
    $query = new CGI;

    }
    else {
    $cgi = 0;
    }


    # get date from localtime
    my(@date) = localtime();
    # localtime returns the month as 0-11, Ugh
    $date[4]++;
    my($date) = scalar localtime();

    # Month name to number hash
    my(%months) = ( "Jan" => 1,
    "Feb" => 2,
    "Mar" => 3,
    "Apr" => 4,
    "May" => 5,
    "Jun" => 6,
    "Jul" => 7,
    "Aug" => 8,
    "Sep" => 9,
    "Oct" => 10,
    "Nov" => 11,
    "Dec" => 12);

    # select_app is a regular expression that will allow users to report only on selected
    # applications
    my($select_app)="/.*/";

    #Use the dates given on the command line to find what period to look at
    my ($todate, $fromdate);
    if ( ! $cgi ) {
    if ( $ARGV[0] ) {
    $fromdate = $ARGV[0];
    }
    else {
    $fromdate = "01.01.2002.00.00.00";
    }
    if ( $ARGV[1] ) {
    $todate = $ARGV[1];
    }
    else {
    $todate = sprintf("%02d.%02d.%04d.%02d.%02d.%02d",$date[3],
    $date[4],
    $date[5]+1900,
    $date[2],
    $date[1],
    $date[0]
    );
    }
    # Allow the user to select a specific app to report on
    # This can be a regular expression to select multiple apps
    if ( $ARGV[2] ) {
    $select_app = $ARGV[2];
    }
    if ( $ARGV[3] ) {
    $debug = $ARGV[3];
    }
    }
    else {
    if ( $cgi && $query->param('start-mon') ) {
    $fromdate = $query->param('start-day') . "." .
    $months{$query->param('start-mon')} . "." .
    $query->param('start-yr')
    ;
    }
    else {
    $fromdate = "01.01.2002.00.00.00";
    }
    if ( $cgi && $query->param('end-mon') ) {
    $todate = $query->param('end-day') . "." .
    $months{$query->param('end-mon')} . "." .
    $query->param('end-yr')
    ;
    }
    else {
    $todate = sprintf("%02d.%02d.%04d.%02d.%02d.%02d",$date[3],
    $date[4],
    $date[5]+1900,
    $date[2],
    $date[1],
    $date[0]
    );

    }
    if ( $query->param('select_app') ) {
    $select_app = $query->param('select_app');
    }
    }

    # if the // start and end the select_app string, then assume its a regular expression,
    # otherwise assume an exact match and append the ^ and $ chars to force the regex interpreter
    # to do the right thing
    if ($select_app =~ /^\/(.*)\/$/) {
    $select_app = $1;
    } else {
    $select_app = "^" . $select_app . "\$";
    }

    my($fromts, $tots) = &find_period_ts($fromdate, $todate);
    if ( $tots > time()) { $tots=time(); }

    &read_config;

    &read_ext_history;

    &read_history;

    &analyze_apps;

    if ( $cgi ) {
    &print_web_results;
    }
    else {
    &print_results;
    }

    exit;

    # -----------------------------------------------------------------------------
    #
    # S U B R O U T I N E S B E L O W T H I S P O I N T !
    #
    # -----------------------------------------------------------------------------
    sub print_event {

  9. #9
    Le modifiche da fare sono le seguenti:

    #!/usr/bin/perl -w

    # sla-report.pl
    #
    use strict;
    use Time::Local;
    #################
    ## prima modifica
    use CGI;
    my $q = CGI->new;


    # -----------------------------------------------------------------------------
    #
    # C O N F I G U R A B L E V A R I A B L E S
    #
    # -----------------------------------------------------------------------------

    # Where the BBHOME is
    # ---------------------------------------------------
    my($bbhome) = "/usr/local/bb";

    # Where to find the history logs to analyze (normally
    # found in your bbvar/hist-directory)
    # ---------------------------------------------------
    my($histdir) = "/usr/local/bbvar/hist";

    # Where to get history external to Big Brother
    # This would include outages that were not caught by
    # big brother, or maintenance enable/disables that
    # weren't sent to bigbrother in time
    my($exthistfile) = "/usr/local/bbvar/ext/sla-report/history.txt";

    # The name of your configfile
    # ---------------------------

    ###########################
    ## seconda modifica
    ## attenzione... devi inserire nell'url di cui al precedente post:
    ## sla-report.pl?userid=valore
    my $userid = $q->param('userid');
    my($configfile) = "$bbhome/ext/sla-report/$userid.cfg";
    Marco Allegretti
    shishii@tiscalinet.it
    Lang: PERL, PHP, SQL.
    Linux user n° 268623 Fedora Core 10, Fedora Core 6, Debian Sarge on mips

  10. #10
    Funziona!!!
    Non credo che ti potrò mai ringraziare abbastanza!
    Grazie a te posso rispettarele mie scadenze sulla tesi!
    Non ho parole!
    Complimenti anche per il tuo sito...utile e interessante soprattutto la sezione sulla sicurezza

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.