Running sql or perl script using DBMS_JOB

Hi,
Is there a way to run a sql or perl script using DBMS_JOB procedures? I have a perl script which checks out the table usage and emails the report to specific users. I want to run this script in a job scheduler, where I am using dbms_job to add the job. Please help. Any suggestions are greatly appreciated. Thanks.
-Kristine

You cannot run sql or perl scrips using DBMS_JOBS. You can run only Oracle procedures, functions, packages with DBMS_JOBS. They have to be stored in the database. You will have to create a Pro*C program that is listening on the pipe and push data to that pipe by using dbms_pipe. Then you can execute anything you want.

Similar Messages

  • Perl script using perldap under unix

    Hi,
    I've got a perl script (used by a UTC instance) which runs on windows NT and which use the perldap API.
    I'm trying to install it on Solaris with the Directory Server 5.1 SP2 and the Meta Directory 5.1 installed.
    When i use the nsperl located in ../iplanet/servers/lib/nsPerl5.005_03, the script works.
    But when i use it with the nsperl located in sunone/servers/bin/utc50/admin/bin (which is used by the UTC instance) it doesn't work.
    The error message is :
    Can't locate loadable object for module Mozilla::LDAP::API in @INC (@INC contains: /var/cyril/sunone/servers/lib/nsPerl5.004_04/lib/sun4-solaris /var/cyril/sunone/servers/lib/nsPerl5.004_04/lib /var/cyril/sunone/servers/lib/nsPerl5.004_04/lib/site_perl/sun4-solaris /var/cyril/sunone/servers/lib/nsPerl5.004_04/lib/site_perl . /LOCAL/nsPerl5.004_04/lib/sun4-solaris /LOCAL/nsPerl5.004_04/lib /LOCAL/nsPerl5.004_04/lib/site_perl/sun4-solaris /LOCAL/nsPerl5.004_04/lib/site_perl .) at /var/cyril/sunone/servers/lib/nsPerl5.004_04/lib/sun4-solaris/Mozilla/LDAP/Utils.pm line 29
    BEGIN failed--compilation aborted at /var/cyril/sunone/servers/lib/nsPerl5.004_04/lib/sun4-solaris/Mozilla/LDAP/Utils.pm line 29, <GEN0> chunk 26.
    BEGIN failed--compilation aborted at /var/cyril/sunone/servers/lib/nsPerl5.004_04/lib/sun4-solaris/Mozilla/LDAP/Conn.pm line 32, <GEN0> chunk 26.
    Does anybody know how to do to avoid this problem ?
    Thanks a lot.

    The message indicates PerLDAP is not installed into that Perl library. You could install, but do you need to really? If you need to run PerLDAP Metadirectory scripts, then maybe this would be the only way. But I would check with support - this may not be supported - changing the Perl install with Metadirectory. But they should be able to tell you how. If you don't need to run the PerLDAP Meta-scripts, then just use a seperate Perl install from the ones that come with the Sun servers. We use #!/usr/local/bin/perl.

  • Getting the output from a Perl script using Runtime.exec

    I cannot get the output from a perl script using Java. Can someone PLEASE help?
    I used the following code:
    Process p = Runtime.getRuntime().exec("C:\\Perl\\bin\\Perl.exe script.pl) ;
    InputSream in = p.getInputStream();
    b...
    do
    System.out.println(b);
    while ((b = in.read()) > 0)
    But there is no way that I get the output in the inputstream. If I use the command "cmd script.pl", the output is displayed in the Dos box, but also not in the inputstream.
    I will appreciate any help.

    Try this
    Process p = Runtime.getRuntime().exec("C:\\Perl\\bin\\Perl.exe script.pl) ;
    BufferedReader rd = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String str;
    while((str=rd.readLine())!=null){
    System.out.println(str);
    Manu

  • Is there a way to get long running SQL Agent jobs information using powershell?

    Hi All,
    Is there a way to get long running SQL Agent jobs information using powershell for multiple SQL servers in the environment?
    Thanks in Advance.
    --Hunt

    I'm running SQL's to fetch the required details and store it in centralized table. 
    foreach ($svr in get-content "f:\PowerSQL\Input\LongRunningJobsPowerSQLServers.txt"){
    $dt = new-object "System.Data.DataTable"
    $cn = new-object System.Data.SqlClient.SqlConnection "server=$svr;database=master;Integrated Security=sspi"
    $cn.Open()
    $sql = $cn.CreateCommand()
    $sql.CommandText = "SELECT
    @@SERVERNAME servername,
    j.job_id AS 'JobId',
    name AS 'JobName',
    max(start_execution_date) AS 'StartTime',
    max(stop_execution_date)AS 'StopTime',
    max(avgruntimeonsucceed),
    max(DATEDIFF(s,start_execution_date,GETDATE())) AS 'CurrentRunTime',
    max(CASE WHEN stop_execution_date IS NULL THEN
    DATEDIFF(ss,start_execution_date,stop_execution_date) ELSE 0 END) 'ActualRunTime',
    max(CASE
    WHEN stop_execution_date IS NULL THEN 'JobRunning'
    WHEN DATEDIFF(ss,start_execution_date,stop_execution_date)
    > (AvgRunTimeOnSucceed + AvgRunTimeOnSucceed * .05) THEN 'LongRunning-History'
    ELSE 'NormalRunning-History'
    END) 'JobRun',
    max(CASE
    WHEN stop_execution_date IS NULL THEN
    CASE WHEN DATEDIFF(ss,start_execution_date,GETDATE())
    > (AvgRunTimeOnSucceed + AvgRunTimeOnSucceed * .05) THEN 'LongRunning-NOW'
    ELSE 'NormalRunning-NOW'
    END
    ELSE 'JobAlreadyDone'
    END)AS 'JobRunning'
    FROM msdb.dbo.sysjobactivity ja
    INNER JOIN msdb.dbo.sysjobs j ON ja.job_id = j.job_id
    INNER JOIN (
    SELECT job_id,
    AVG
    ((run_duration/10000 * 3600) + ((run_duration%10000)/100*60) + (run_duration%10000)%100)
    +
    STDEV
    ((run_duration/10000 * 3600) + ((run_duration%10000)/100*60) + (run_duration%10000)%100) AS 'AvgRuntimeOnSucceed'
    FROM msdb.dbo.sysjobhistory
    WHERE step_id = 0 AND run_status = 1
    GROUP BY job_id) art
    ON j.job_id = art.job_id
    WHERE
    (stop_execution_date IS NULL and start_execution_date is NOT NULL) OR
    (DATEDIFF(ss,start_execution_date,stop_execution_date) > 60 and DATEDIFF(MINUTE,start_execution_date,GETDATE())>60
    AND
    CAST(LEFT(start_execution_date,11) AS DATETIME) = CAST(LEFT(GETDATE(),11) AS DATETIME) )
    --ORDER BY start_execution_date DESC
    group by j.job_id,name
    $rdr = $sql.ExecuteReader()
    $dt.Load($rdr)
    $cn.Close()
    $dt|out-Datatable
    Write-DataTable -ServerInstance 'test124' -Database "PowerSQL" -TableName "TLOG_JobLongRunning" -Data $dt}
    You can refer the below link to refer out-datatable and write-dataTable function.
    http://blogs.technet.com/b/heyscriptingguy/archive/2010/11/01/use-powershell-to-collect-server-data-and-write-to-sql.aspx
    Once we've the table details, I'm sending one consolidated email to automatically.
    --Prashanth

  • Perl script -use essbase

    In perl script , I am using
    use essbase; (This statement is required to use Essbase within a Perl script)
    But while compiling the perl script , this line is giving error (use essbase;)
    Do we need any prerequisites in order to utilze the command "use essbase"

    Successfully installed Runtime client (including ESSCMD and MaxL) on Win 2k machine and tested Essbase.pm functionality using regular Perl script (/sample/table.pl).Problem: trying to "use Essbase;" in a Perl CGI script running under Apache generates following error:"Can't load 'c:/Perl/site/lib/auto/Essbase/Essbase.dll' for module Essbase: load_file:The specified module could not be found at c:/Perl/lib/Dynaloader.pm line 206."Any one found a way to "use Essbase;" in a Perl CGI script?

  • How to pass ouput from PL/SQL to perl script

    Hi !
    I have a PL/SQL package which returns REF CURSOR. How can I pass this ref cursor to perl script?
    can any one help me in this matter, pl? it is very very urgent.
    Thanks
    ..mvp

    Thanks for the help but I can't use DBI, we sre using SQLPLUS. So if u can give me any examples on it.
    Thanks
    ..mvp

  • Capturing Users with running sql in shell script after every 10min

    Hi All,
    we have a strange prob. of database crash, therefore decided to check what users do when OS/DB crashes,
    i need your input in RUNNING/SCHEDULING such a script which gathers all active users with running SQL and append in a logfile so that we are aware of what happened when DB/OS Crashed.
    i can run this run a query from V$SESSION,V$SQL, and V$PROCESS but i need your input writing such a SHELL Script and scheduling can run by CRON.
    Regards.

    Here ya go.
    (Assuming you want a script to run against one sid)
    script:
    #!/bin/ksh
    # Set environment
    . $HOME/.profile
    export ORACLE_SID=your sid
    sqlplus <<! > /some_report_file
    / as sysdba
    sql you want to execute here*
    exit
    cron entry:
    0,5,10,15,20,25,30,35,40,45,50,55 * * * * /your/script/name/here > /dev/null 2>&1

  • Execute perl-script using java

    Hi All
    I would like to execute a perl script (inside a java app) and retrieve its output. This java program needs this output.
    Can someone give me information on how to do this ?
    Thanks a lot in advance
    Luca

    Ok, solved it:
    import java.lang.Runtime ;
    import java.io.* ;
    public class Test {
         public static void main ( String ARGV[] ) {
              Runtime r = Runtime.getRuntime() ;
              Process p = null ;
              DataInputStream dis = null ;
              String s ;
              try {
                   String cmd[] = new String[1] ;
                   cmd[0] = "./a.pl" ;
                   p = r.exec(cmd) ;
              dis = new DataInputStream(p.getInputStream());     // create file I/O
                   s = dis.readLine();     
                   System.out.println("|"+s+"|") ;
                   s = dis.readLine();     
                   System.out.println("|"+s+"|") ;
              catch(IOException e) {}
    }

  • Help: Running iTunes U perl script: Can't locate Digest/SHA.pm

    We are using IIS 6.0 on Windows Server 2003.
    We have installed v5.008008 of Active Perl.
    We changed the sample iTunesU.pl script with our school data
    When we run the script from the command prompt we get the following error:
    Can't locate Digest/SHA.pm in @INC (@INC contains: E:/Perl/site/lib E:/Perl/lib
    .) at E:\Webapps\ajula\CGI\ITunesU.pl line 87.
    BEGIN failed--compilation aborted at E:\Webapps\ajula\CGI\ITunesU.pl line 87.
    How can fix this problem
    Thanks
    Moshe AJULA.EDU

    I followed the instructions in the sample files.
    On the server I ran perl -MCPAN -e shell
    It showed errors and problem for when installing Digest::SHA and Crypt::SSLeay
    Here is a copy of the restults.
    Can you help me figuring out what is wrong?
    Thanks
    -------------------------- Resutls of install --------------------
    In the cpan> prompt
    cpan shell -- CPAN exploration and modules installation (v1.9102)
    ReadLine support enabled
    cpan> install URI::Escape
    CPAN: Storable loaded ok (v2.16)
    Going to read E:\Perl\cpan\Metadata
    Database was generated on Mon, 26 Nov 2007 10:36:39 GMT
    URI::Escape is up to date (3.28).
    cpan> install Digest::SHA
    Running install for module 'Digest::SHA'
    Running make for M/MS/MSHELOR/Digest-SHA-5.45.tar.gz
    CPAN: checksum security checks disabled because Digest::SHA not installed.
    Please consider installing the Digest::SHA module.
    CPAN: Time::HiRes loaded ok (v1.9707)
    Scanning cache E:\Perl/cpan/build for sizes
    ............................................................................DONE
    CPAN: Compress::Zlib loaded ok (v1.4201)
    CPAN: Archive::Tar loaded ok (v1.3201)
    Digest-SHA-5.45/
    Digest-SHA-5.45/README
    Digest-SHA-5.45/src/
    Digest-SHA-5.45/src/hmac.h
    Digest-SHA-5.45/src/hmacxtra.c
    Digest-SHA-5.45/src/sha.h
    Digest-SHA-5.45/src/shaxtra.c
    Digest-SHA-5.45/src/sha64bit.h
    Digest-SHA-5.45/src/sha64bit.c
    Digest-SHA-5.45/src/hmac.c
    Digest-SHA-5.45/src/sha.c
    Digest-SHA-5.45/Makefile.PL
    Digest-SHA-5.45/examples/
    Digest-SHA-5.45/examples/dups
    Digest-SHA-5.45/META.yml
    Digest-SHA-5.45/Changes
    Digest-SHA-5.45/shasum
    Digest-SHA-5.45/typemap
    Digest-SHA-5.45/MANIFEST
    Digest-SHA-5.45/SHA.pm
    Digest-SHA-5.45/t/
    Digest-SHA-5.45/t/nistbyte.t
    Digest-SHA-5.45/t/nistbit.t
    Digest-SHA-5.45/t/rfc2202.t
    Digest-SHA-5.45/t/bitbuf.t
    Digest-SHA-5.45/t/hmacsha.t
    Digest-SHA-5.45/t/podcover.t
    Digest-SHA-5.45/t/methods.t
    Digest-SHA-5.45/t/sha224.t
    Digest-SHA-5.45/t/dumpload.t
    Digest-SHA-5.45/t/sha384.t
    Digest-SHA-5.45/t/sha1.t
    Digest-SHA-5.45/t/sha512.t
    Digest-SHA-5.45/t/gg.t
    Digest-SHA-5.45/t/allfcns.t
    Digest-SHA-5.45/t/gglong.t
    Digest-SHA-5.45/t/pod.t
    Digest-SHA-5.45/t/woodbury.t
    Digest-SHA-5.45/t/fips198.t
    Digest-SHA-5.45/t/ireland.t
    Digest-SHA-5.45/t/base64.t
    Digest-SHA-5.45/t/sha256.t
    Digest-SHA-5.45/SHA.xs
    CPAN: File::Temp loaded ok (v0.18)
    CPAN.pm: Going to build M/MS/MSHELOR/Digest-SHA-5.45.tar.gz
    Checking if your kit is complete...
    Looks good
    Writing Makefile for Digest::SHA
    Could not read 'E:\Perl\cpan\build\Digest-SHA-5.45-KfEI5d\META.yml'. Falling bac
    k to other methods to determine prerequisites
    'nmake' is not recognized as an internal or external command,
    operable program or batch file.
    MSHELOR/Digest-SHA-5.45.tar.gz
    nmake -- NOT OK
    Warning (usually harmless): 'YAML' not installed, will not store persistent stat
    e
    Running make test
    Can't test without successful make
    Running make install
    Make had returned bad status, install seems impossible
    Failed during this command:
    MSHELOR/Digest-SHA-5.45.tar.gz : make NO
    cpan> install LWP::UserAgent
    LWP::UserAgent is up to date (2.036).
    cpan> install Crypt::SSLeay
    Running install for module 'Crypt::SSLeay'
    Running make for D/DL/DLAND/Crypt-SSLeay-0.57.tar.gz
    CPAN: LWP::UserAgent loaded ok (v2.036)
    Fetching with LWP:
    http://ppm.activestate.com/CPAN/authors/id/D/DL/DLAND/Crypt-SSLeay-0.57.tar.gz
    CPAN: checksum security checks disabled because Digest::SHA not installed.
    Crypt-SSLeay-0.57
    Crypt-SSLeay-0.57/t
    Crypt-SSLeay-0.57/Changes
    Crypt-SSLeay-0.57/lib
    Crypt-SSLeay-0.57/certs
    Crypt-SSLeay-0.57/MANIFEST
    Crypt-SSLeay-0.57/TODO
    Crypt-SSLeay-0.57/typemap
    Crypt-SSLeay-0.57/MANIFEST.SKIP
    Crypt-SSLeay-0.57/eg
    Crypt-SSLeay-0.57/SSLeay.pm
    Crypt-SSLeay-0.57/SSLeay.xs
    Crypt-SSLeay-0.57/README
    Crypt-SSLeay-0.57/Makefile.PL
    Crypt-SSLeay-0.57/META.yml
    Crypt-SSLeay-0.57/eg/lwp-ssl-test
    Crypt-SSLeay-0.57/eg/net-ssl-test
    Crypt-SSLeay-0.57/certs/ca-bundle.crt
    Crypt-SSLeay-0.57/certs/notacakeynopass.pem
    Crypt-SSLeay-0.57/certs/notacacert.pem
    Crypt-SSLeay-0.57/lib/Crypt
    Crypt-SSLeay-0.57/lib/Net
    Crypt-SSLeay-0.57/lib/Net/SSL.pm
    Crypt-SSLeay-0.57/lib/Crypt/SSLeay
    Crypt-SSLeay-0.57/lib/Crypt/SSLeay/MainContext.pm
    Crypt-SSLeay-0.57/lib/Crypt/SSLeay/Conn.pm
    Crypt-SSLeay-0.57/lib/Crypt/SSLeay/X509.pm
    Crypt-SSLeay-0.57/lib/Crypt/SSLeay/Err.pm
    Crypt-SSLeay-0.57/lib/Crypt/SSLeay/CTX.pm
    Crypt-SSLeay-0.57/t/00-basic.t
    Crypt-SSLeay-0.57/t/02-live.t
    Crypt-SSLeay-0.57/t/01-connect.t
    CPAN.pm: Going to build D/DL/DLAND/Crypt-SSLeay-0.57.tar.gz
    ========================================================================
    No installed SSL libraries found in any of the following places.
    c:\openssl
    You will have to either specify a directory location at the following
    prompt, or rerun the Makefile.PL program and use the --lib switch
    to specify the path. If the path in question is considered standard
    on your platform, please consider filing a bug report in order to
    have it taken into account in a subsequent version of Crypt::SSLeay.
    Which SSL install path do you want to use? c:\openssl
    c:\openssl does not appear to be an SSL library installation, since
    the required header files were not found. The build cannot proceed.
    Warning: No success on command[E:\Perl\bin\perl.exe Makefile.PL]
    Warning (usually harmless): 'YAML' not installed, will not store persistent stat
    e
    DLAND/Crypt-SSLeay-0.57.tar.gz
    E:\Perl\bin\perl.exe Makefile.PL -- NOT OK
    Running make test
    Make had some problems, won't test
    Running make install
    Make had some problems, won't install
    Could not read 'E:\Perl\cpan\build\Crypt-SSLeay-0.57-5QWh9O\META.yml'. Falling b
    ack to other methods to determine prerequisites
    Failed during this command:
    DLAND/Crypt-SSLeay-0.57.tar.gz : writemakefile NO 'E:\Perl\bin\pe
    rl.exe Makefile.PL' returned status 512

  • Anyone running ArcGIS arcpy Python scripts using Oracle 11g EM AGENT?

    I have a Windows command file that successfully executes an ArcGIS arcpy Python script when run manually or via Task Scheduler . But when executed by the EM Agent, arcpy doesn't recognize the SDE connection string file as a workspace for connecting to the geodatabase. The manual execution on the server uses the same login as the EM Agent.
    I have verified all the environment variables for the EM Agent are the same as those for running natively on the server. I then used arcpy to describe the file type using both execution methods.
    DescribeFile.py
    import os
    import sys
    import arcpy
    desc arcpy.Describe("D:\\Test\\Compress\\database_login.sde")
    print desc.dataElementType
    Manual output of: python.exe DescribeFile.py >> DEWorkspace
    EM Agent output of: python.exe DescribeFile.py >> DEFile
    I have little experience with Python, but years of experience with the EM Agent. I have been unable to find anything related that was helpful on Oracle Support, ESRI support, or general internet searches.

    I am a non arcpy user but should it not be desc =
    Or is it a typo?
    And maybe try using / instead of \\
    Eric

  • How to run NMS perl scripts in SunONE 6.1

    Any one have info on running the NMS perl scripts with the perl compiler shipped with 6.1? Particularly interested in nms FormMail. I need to get it running in on windows xp and Sun Solaris.
    WebServer is reporting the following error.
    failure: for host dbmrpm41.deluxe.com trying to POST /cgi-bin/FormMail.pl, cgi_s
    can_headers reports: HTTP4044: the CGI program C:\Sun\WebServer6.1\bin\https\per
    l\perl.exe did not produce a valid header (program terminated without a valid CG
    I header. Check for core dump or other abnormal termination)
    When I run FormMail.pl in a command prompt, I receive the following:
    Can't locate auto/POSIX/autosplit.ix in @INC (@INC contains: C:/Sun/WebServer6.1
    /bin/https/perl/lib/MSWin32-x86 C:/Sun/WebServer6.1/bin/https/perl/lib) at C:/Su
    n/WebServer6.1/bin/https/perl/lib/AutoLoader.pm line 146.
    at C:/Sun/WebServer6.1/bin/https/perl/lib/MSWin32-x86/POSIX.pm line 5
    Edited by: garyb on Mar 18, 2008 9:04 AM

    The Perl you found in the bin/https/perl directory is a private copy of Perl used to implement parts of the Web Server Administration Server. You shouldn't try to use it to run CGI scripts.
    Instead, you can download your own Perl distribution. ActiveState has a Perl distribution called ActivePerl. You can get it for free from http://www.activestate.com/Products/activeperl/. Other options are listed at http://win32.perl.org/.

  • Unix Perl Script To verify a Up and Running Database on Different Server

    Unix Perl Script To verify a Up and Running Database on Different Server
    Hi
    can any one please tell me a solution to verify a Up and Running Database on Different Server other than the one where we run the unix perl script? The perl script should check if the database is running else it must exit.
    Thanks much
    Kiran

    The other best solution would be Enterprise Manager, load the EM on the other machine and install oracle intelligent agent on all the boxes where oracle is running and problem solved.
    FTP is only a File Transfer Protocol, you can upload/download the files but cant execute them.
    Apart from EM the best way is load oracle client and make connection to all the databases.
    AND There are some free oracle monitoring software available I dont know much about them but one is NAGIO (if I am not wrong), try that if you want.
    BTW whats the problem in monitoring the boxes from the same physical box, means just schedule a script using cron on the same physical box where oracle is to either make connection using SQLPLUS or check the processes using "ps" command and if there is anything wrong then send alert from that box only. In this way there is no need to maintain a central monitoring server.
    Daljit Singh

  • ANM VA - run perl script to obtain and genarate reports.

    Good day,
    We have a customer who has an ANM deployment at a site. This is a HA deployment on RedHat. The customer created a perl script to run off an external host to generate reports. This was acheievd by querying the sqldatabase (dcm_ems). ANM version is 3.2. No problems.
    An additional ANM deployment was done on another site. ANM version 4.2. This deployment is the VA edition. They would like to deploy and run the same perl script.
    Is this possible on the VA Edition? Even with the RootPatch? Not sure of the level of access the patch provides, or if it is even recommened or would then still allow for the ANM to be supported? If possible, has the sqldatabase structure changed (suppose would need this for the guy's to ammend the script)? How would we obtain the "sqluser" and "sqlpwd" info for the perl script to use?
    Appreciate any guidance or feedback.
    Thank you in advance.
    Paul.

    Hi esteemed forum members,
    Any ideas or feedback anyone?
    Thanks.
    Paul.

  • Screen message when run SQL / PLSQ script

    Hi
    Can anyone tell me how desactivate the message :
    "Entry limited at xx caracters" ("Entree limitee a xx caracteres" in french) when running sql or plsql script ?
    Thanks
    it's like this:
    EntrÚe limitÚe Ó 17 caractÞres

    I suppose you are talking about the message
    "Input truncated to (number) characters."
    This is caused by not having a carriage return at the end of the line.

  • How to launching a perl script by the "begin" script of a jumpstart

    Hi all,
    i have an urgent pb with my solaris jumpstart, let me explain to you :
    i want that the begin script launch some perl script, but i have a problem
    here is my "begin" script:
    echo "Begining ISO FLAR based jumpstart."
    echo ""
    echo "Starting Ullink Configuration"
    env > /tmp/env
    /bin/sh << EOF
    /usr/bin/perl /cdrom/.archives/admin-scripts/sethostname.pl
    EOFmy perl script use a STDIN
    with this configuration, the perl script is launching but it runs in a loop indefinitely with an error "use of uninitialized value", because (i think) a value is return to the begin scritp and not to the perl script.
    well, on a pre-installed solaris, if a launch the begin script, it happens the same thing, it runs in a loop, BUT if i comment the line "/bin/sh <<EOF" and "EOF", it works.
    at this step, i say "ok it's cool my script is working", but when i use it during the jumpstart instalaltion, the perl script does not start, without any particular error.
    here is my perl script, if you want to test :
    #!/usr/bin/perl -w^M
    # Set Hostname for Ullink Jumpstart^M
    ^M
    use strict;^M
    ^M
    sub hit_enter {^M
        print "Hit enter to continue\n";^M
        <STDIN>;^M
        print "\033[2J";^M
    }^M
    ^M
    sub get_hostname {^M
        my %towns_list = (^M
            'Paris' => 'PA',^M
            'New-York' => 'NY',^M
        );^M
    ^M
        my %sites_list = (^M
            'Office' => 'OFC',^M
            'Redbus' => 'RED',^M
            'Telehouse' => 'TLH',^M
            'DTC' => 'DTC',^M
            'iAdvantage' => 'IAD',^M
            'Nutley' => 'NUT',^M
            'Level3' => 'LV3',^M
            'Equinix' => 'EQX',^M
            'Tata' => 'TAT',^M
            'Switch-data' => 'SWI',^M
            );^M
    ^M
        my %usage_list = (^M
            'Production' => 'PRD',^M
            'UAT' => 'UAT',^M
            'DMZ' => 'DMZ',^M
        );^M
    ^M
        sub select_list {^M
            my $counter=-1;^M
            my %hash_list = @_;^M
            my @keys = keys %hash_list;^M
    ^M
            # Clear screen^M
            print "\033[2J";^M
            print "In which country this machine is hosted or will be host and will be used ?\n\n";^M
    ^M
            # Get all keys from hash^M
            my $key;
            while ($key = each %hash_list ) {^M
                $counter++;^M
                print "$counter - $key\n";^M
            }^M
    ^M
            print "\nChoose the number corresponding to your choice :\n";^M
            my $choice_number;
            chomp ($choice_number = <STDIN>);^M
    ^M
            # Verify answer^M
            if (($choice_number =~ /\d+/) and ($choice_number <= $counter)) {^M
                # Add choice to chosen hostname^M
                my $chosen=$hash_list{$keys[$choice_number]};^M
                return $chosen;^M
            } else {^M
                print "\nYour answer is not correct, you need to enter a number between 0 and $counter\n";^M
                &hit_enter;^M
                &select_list;^M
            }^M
        }^M
    ^M
        sub srv_number {^M
            print "\033[2J";^M
            print "What is the server number ?\n";^M
            my $server_number;
            chomp ($server_number = <STDIN>);^M
            if ($server_number =~ /\d+/) {^M
                return $server_number;^M
            } else {^M
                print "\nYour answer is not correct, you need to enter a number\n";^M
                &hit_enter;^M
                &srv_number;^M
            }^M
        }^M
    ^M
        my $full_hostname = &select_list(%towns_list).'-';^M
        $full_hostname = $full_hostname.&select_list(%sites_list).'-';^M
        $full_hostname = $full_hostname.'SRV-';^M
        $full_hostname = $full_hostname.&select_list(%usage_list).'-';^M
        $full_hostname = $full_hostname.&srv_number;^M
    ^M
        sub write_hostname2tmp {^M
            open (HOSTNAME, ">/tmp/set_hostname") or warn "Couldn't write $_[0] to temp file : $!\n";^M
                print HOSTNAME "$_[0]\n";^M
            close (HOSTNAME);^M
        }^M
    ^M
        print "\033[2J";^M
        print "Is $full_hostname the correct name for this server ? (y/n)\n";^M
        if (<STDIN> =~ /y|yes/i) {^M
            &write_hostname2tmp($full_hostname);^M
        } else {^M
            print "Would you like to retry (r) or set manually the hostname (s) ? (r/s)\n";^M
            if (<STDIN> =~ /s/i) {^M
                print "Type the full required name and hit enter when finished :\n";^M
                chomp ($full_hostname = <STDIN>);^M
                &write_hostname2tmp;^M
            } else {^M
                &get_hostname;^M
            }^M
        }^M
    }^M
    ^M
    # Start configuration^M
    print "\033[2J";^M
    print "\n########################################################\n";^M
    print "#\t\t\t\t\t\t       #\n";^M
    print "#\t\t\tULLINK\t\t\t       #\n";^M
    print '#  Solaris Environnement Installation for Datacenters  #';^M
    print "\n#\t\t\t\t\t\t       #";^M
    print "\n########################################################\n\n";^M
    print "Before starting installation, you need to enter a set of informations.\n(answer to all questions, you can Ctrl+C to stop now)\n\n";^M
    &hit_enter;^M
    ^M
    &get_hostname;^Mthank for your help
    Edited by: ullink on Jun 25, 2009 6:05 AM

    Hi Manju,
    You can try the following command and check if any helps:
    Get-Exchangeserver |where-object{$_.AdminDisplayVersion -like "Version 15*"} |Get-MailboxStatistics | Ft -auto -wrap DisplayName,database,servername,*size*,*time*
    Best regards,
    Niko Cheng
    TechNet Community Support

Maybe you are looking for