Query SQL and output to text file then loop through list to execute

It seems there's no obvious way to do what I want to below as everyone has their own take on querying SQL server with Powershell!
I need to use PowerShell to connect to ServerA and query a test database and select Name from it.  The Name results of that query need to output to C:\names.txt and then I need a ForEach loop to go through that file line by line and execute some text
against each Name from the list.
Any ideas how I can achieve this?
Thanks!

I can't even output SQl to a table at the moment, the text file has a column header and about 50 empty rows in the file.
$dataSource = "DEMO"
$database = "TESTDB"
$connectionString = "Server=$dataSource;uid=$user; pwd=$pwd;Database=$database;Integrated Security=True;"
$query = "SELECT name FROM dbo.names"
$connection = New-Object System.Data.SqlClient.SqlConnection
$connection.ConnectionString = $connectionString
$connection.Open()
$command = $connection.CreateCommand()
$command.CommandText  = $query
$result = $command.ExecuteReader()
$table = new-object "System.Data.DataTable"
$table.Load($result)
$format = @{Expression={$_.Id};Label="Name";width=25}
$table | format-table $format | Out-File C:\export\servers.txt
$connection.Close()

Similar Messages

  • SQL query automation and output to text file

    The bcp utility should handle this task pretty easily for you. The documentation is available here.

    I know enough SQL to get me by with the few things I currently do in it (but would always like to know and do more).  Anyway, I was just recently asked if I could come up with a way to automate the execution of a SQL query we currently manually run, and then have the results of that query output (instead of to the screen in SSMS) to a text file with the ".dat" extension.  I've never automated a SQL query before nor have I had the results output to a file.  Can anyone give me some pointers on how to tackle this?
    The query currently calls to a stored procedure (which does all the work) and just executes it with some given dates from the query so I'm thinking the output will need to come from the stored procedure (and the code for output to a file added there?)
    This topic first appeared in the Spiceworks Community

  • How to list the contents of an OSX directory, and output to text file?

    hello there any hints with any known program that does following
    I have recorded my music directory to DVD and now i would like to make an .txt file what the dvd contains...cos its way of hand to write all 100xx files by hand...
    How to list the contents of an OSX directory, and output to text file?
    any prog that does that? any hints?
    best regards

    This script makes a hierarchical file listing all files in a folder and subfolder:
    Click here to launch Script Editor.
    choose folder with prompt "Choose a folder to process..." returning theFolder
    set theName to name of (info for theFolder)
    set thepath to quoted form of POSIX path of theFolder
    set currentIndex to theFolder as string
    do shell script "ls -R " & thepath returning theDir
    set theDirList to every paragraph of theDir
    set newList to {"Contents of folder \"" & theName & "\"" & return & thepath & return & return}
    set theFilePrefix to ""
    repeat with i from 1 to count of theDirList
    set theLine to item i of theDirList
    set my text item delimiters to "/"
    set theMarker to count of text items of thepath
    set theCount to count of text items of theLine
    set currentFolder to text item -1 of theLine
    set theFolderPrefix to ""
    if theCount is greater than theMarker then
    set theNestIndex to theCount - theMarker
    set theTally to -1
    set theFilePrefix to ""
    set theSuffix to ""
    repeat theNestIndex times
    set theFolderPrefix to theFolderPrefix & tab
    set theFilePrefix to theFilePrefix & tab
    if theTally is -1 then
    set theSuffix to text item theTally of theLine & theSuffix
    else
    set theSuffix to text item theTally of theLine & ":" & theSuffix
    end if
    set currentIndex to "" & theFolder & theSuffix
    set theTally to theTally - 1
    end repeat
    end if
    set my text item delimiters to ""
    if theLine is not "" then
    if word 1 of theLine is "Volumes" then
    set end of newList to theFolderPrefix & "Folder: > " & currentFolder & return
    else
    try
    if not folder of (info for alias (currentIndex & theLine & ":")) then
    set end of newList to theFilePrefix & tab & tab & tab & "> " & theLine & return
    end if
    end try
    end if
    end if
    end repeat
    open for access file ((path to desktop as string) & "Contents of folder- " & theName & ".txt") ¬
    with write permission returning theFile
    write (newList as string) to theFile
    close access theFile

  • How to generate complete file list of hard drive and output to text file

    I need to start backing things up to drives, which over time will be put in storage.
    I would like to be able to create a complete file index and folder tree of every drive and have it output to a text file so that in the event I ever need to go back to a drive, I can search the text file to know what drive to pull from storage (rather than using spotlight to search through 25 drives).
    Is there any way to do this with either OS X or with a third party software? Ideally, text file and not PDF.
    Thanks!

    You can use the terminal.app with the following command:
    rsync -rlptn --stats --progress +Source.. Destination..+
    example with actual output:
    rsync -rlptn --stats --progress /Volumes/Mac\ Data/websites /Volumes/EXT\ SATA2building file list ...
    146 files to consider
    websites/
    websites/.DS_Store
    websites/bestelectricbill.com/
    websites/bestelectricbill.com/.DS_Store
    websites/bestelectricbill.com/211299c1
    websites/bestelectricbill.com/awards.php
    websites/bestelectricbill.com/careers.php
    websites/bestelectricbill.com/category1.php
    websites/bestelectricbill.com/category2.php
    websites/bestelectricbill.com/category3.php
    websites/bestelectricbill.com/checkout.php
    websites/bestelectricbill.com/company.php
    websites/bestelectricbill.com/contactus.php
    websites/bestelectricbill.com/email.js
    websites/bestelectricbill.com/faqs.php
    websites/bestelectricbill.com/fsp.js
    websites/bestelectricbill.com/history.php
    websites/bestelectricbill.com/index.php
    websites/bestelectricbill.com/index_copy.php
    websites/bestelectricbill.com/investors.php
    websites/bestelectricbill.com/job1.php
    websites/bestelectricbill.com/job2.php
    websites/bestelectricbill.com/job3.php
    websites/bestelectricbill.com/job4.php
    websites/bestelectricbill.com/job5.php
    websites/bestelectricbill.com/managementteam.php
    websites/bestelectricbill.com/news1.php
    websites/bestelectricbill.com/news2.php
    websites/bestelectricbill.com/news3.php
    websites/bestelectricbill.com/news4.php
    websites/bestelectricbill.com/news5.php
    websites/bestelectricbill.com/newsandevents.php
    websites/bestelectricbill.com/partners.php
    websites/bestelectricbill.com/press.php
    websites/bestelectricbill.com/privacypolicy.php
    websites/bestelectricbill.com/product1a.php
    websites/bestelectricbill.com/product1a1.php
    websites/bestelectricbill.com/product1a2.php
    websites/bestelectricbill.com/product1b.php
    websites/bestelectricbill.com/product1b1.php
    websites/bestelectricbill.com/product1b2.php
    websites/bestelectricbill.com/product1c.php
    websites/bestelectricbill.com/product1c1.php
    websites/bestelectricbill.com/product1c2.php
    websites/bestelectricbill.com/product1d.php
    websites/bestelectricbill.com/product1d1.php
    websites/bestelectricbill.com/product1d2.php
    websites/bestelectricbill.com/product1e.php
    websites/bestelectricbill.com/product1e1.php
    websites/bestelectricbill.com/product1e2.php
    websites/bestelectricbill.com/products.php
    websites/bestelectricbill.com/productsearch.php
    websites/bestelectricbill.com/registration.php
    websites/bestelectricbill.com/search.php
    websites/bestelectricbill.com/searchresults.php
    websites/bestelectricbill.com/service1.php
    websites/bestelectricbill.com/service1a.php
    websites/bestelectricbill.com/service1a1.php
    websites/bestelectricbill.com/service1a2.php
    websites/bestelectricbill.com/service1b.php
    websites/bestelectricbill.com/service1b1.php
    websites/bestelectricbill.com/service1b2.php
    websites/bestelectricbill.com/service1c.php
    websites/bestelectricbill.com/service1c1.php
    websites/bestelectricbill.com/service1c2.php
    websites/bestelectricbill.com/service1d.php
    websites/bestelectricbill.com/service1d1.php
    websites/bestelectricbill.com/service1d2.php
    websites/bestelectricbill.com/service1e.php
    websites/bestelectricbill.com/service1e1.php
    websites/bestelectricbill.com/service1e2.php
    websites/bestelectricbill.com/service2.php
    websites/bestelectricbill.com/service3.php
    websites/bestelectricbill.com/services.php
    websites/bestelectricbill.com/shoppingcart.php
    websites/bestelectricbill.com/sitemap.php
    websites/bestelectricbill.com/story1.php
    websites/bestelectricbill.com/story2.php
    websites/bestelectricbill.com/story3.php
    websites/bestelectricbill.com/termsofuse.php
    websites/bestelectricbill.com/Templates/
    websites/bestelectricbill.com/Templates/siteassist_config.cfg
    websites/bestelectricbill.com/Templates/siteassist_template.dwt.php
    websites/bestelectricbill.com/Templates/_notes/
    websites/bestelectricbill.com/Templates/_notes/dwsync.xml
    websites/bestelectricbill.com/_notes/
    websites/bestelectricbill.com/_notes/dwsync.xml
    websites/bestelectricbill.com/images/
    websites/bestelectricbill.com/images/.DS_Store
    websites/bestelectricbill.com/images/app_img17.jpg
    websites/bestelectricbill.com/images/bestelectriclogo.jpg
    websites/bestelectricbill.com/images/bestelectriclogo.jpg.ori.jpg
    websites/bestelectricbill.com/images/btn_saveBusiness.jpg
    websites/bestelectricbill.com/images/btn_saveHome.jpg
    websites/bestelectricbill.com/images/imgAbout_OverviewTeam copy.jpg
    websites/bestelectricbill.com/images/imgCollage.jpg
    websites/bestelectricbill.com/images/imgComp1.jpg
    websites/bestelectricbill.com/images/imgComp3.jpg
    websites/bestelectricbill.com/images/imgComp4.jpg
    websites/bestelectricbill.com/images/imgComp5.jpg
    websites/bestelectricbill.com/images/imgComp6.jpg
    websites/bestelectricbill.com/images/imgComp7.jpg
    websites/bestelectricbill.com/images/imgComp8.jpg
    websites/bestelectricbill.com/images/phone number.jpg
    websites/bestelectricbill.com/images/phone number2.jpg
    websites/bestelectricbill.com/images/_notes/
    websites/bestelectricbill.com/images/_notes/dwsync.xml
    websites/bestelectricbill.com/siteassist_css/
    websites/bestelectricbill.com/siteassist_css/color.css
    websites/bestelectricbill.com/siteassistcss/mystyles.css
    websites/bestelectricbill.com/siteassist_css/navigation.css
    websites/bestelectricbill.com/siteassistcss/navigationcolor.css
    websites/bestelectricbill.com/siteassist_css/style.css
    websites/bestelectricbill.com/siteassist_css/template.css
    websites/bestelectricbill.com/siteassistcss/notes/
    websites/bestelectricbill.com/siteassistcss/notes/dwsync.xml
    websites/bestelectricbill.com/siteassist_images/
    websites/bestelectricbill.com/siteassistimages/above_topnavbackground.jpg
    websites/bestelectricbill.com/siteassistimages/below_topnavbackground.jpg
    websites/bestelectricbill.com/siteassist_images/border.gif
    websites/bestelectricbill.com/siteassistimages/bottombackground.jpg
    websites/bestelectricbill.com/siteassistimages/brcorner.jpg
    websites/bestelectricbill.com/siteassist_images/bubbles.jpg
    websites/bestelectricbill.com/siteassistimages/dottedhorizontal.jpg
    websites/bestelectricbill.com/siteassistimages/dottedvertical.jpg
    websites/bestelectricbill.com/siteassistimages/home_mainbackground.jpg
    websites/bestelectricbill.com/siteassistimages/img100x125.gif
    websites/bestelectricbill.com/siteassistimages/img160x110.gif
    websites/bestelectricbill.com/siteassistimages/img400x197.gif
    websites/bestelectricbill.com/siteassistimages/img463x170.gif
    websites/bestelectricbill.com/siteassistimages/loginbtn.gif
    websites/bestelectricbill.com/siteassistimages/logotraditional.jpg
    websites/bestelectricbill.com/siteassistimages/mainfeature.jpg
    websites/bestelectricbill.com/siteassistimages/side_navcell.gif
    websites/bestelectricbill.com/siteassistimages/side_nav_cellsel.gif
    websites/bestelectricbill.com/siteassistimages/side_nav_opengrad.gif
    websites/bestelectricbill.com/siteassistimages/side_nav_open_selgrad.gif
    websites/bestelectricbill.com/siteassistimages/sidenavbackground.jpg
    websites/bestelectricbill.com/siteassist_images/spacer.gif
    websites/bestelectricbill.com/siteassistimages/topbackground.jpg
    websites/bestelectricbill.com/siteassistimages/topnavbackground.jpg
    websites/bestelectricbill.com/siteassistimages/topnav_cellbg.gif
    websites/bestelectricbill.com/siteassistimages/topnav_cell_bghover.gif
    websites/bestelectricbill.com/siteassistimages/trcorner.jpg
    websites/bestelectricbill.com/siteassistimages/notes/
    websites/bestelectricbill.com/siteassistimages/notes/dwsync.xml
    Number of files: 146
    Number of files transferred: 135
    Total file size: 1150921 bytes
    Total transferred file size: 1150921 bytes
    Literal data: 0 bytes
    Matched data: 0 bytes
    File list size: 2825
    File list generation time: 0.001 seconds
    File list transfer time: 0.000 seconds
    Total bytes sent: 3717
    Total bytes received: 896
    sent 3717 bytes received 896 bytes 9226.00 bytes/sec
    total size is 1150921 speedup is 249.50
    Simply copy and and paste output text in terminal to a text file.
    What I actually did there was use the "dry run option" (-n) - no files were actually transferred.
    For more info on the rsync command type and run "man rsync" at the terminal command line.
    Also see this webpage:
    http://www.ss64.com/osx/rsync.html
    Kj

  • How to load date and time from text file to oracle table through sqlloader

    hi friends
    i need you to show me what i miss to load date and time from text file to oracle table through sqlloader
    this is my data in this path (c:\external\my_data.txt)
    7369,SMITH,17-NOV-81,09:14:04,CLERK,20
    7499,ALLEN,01-MAY-81,17:06:08,SALESMAN,30
    7521,WARD,09-JUN-81,17:06:30,SALESMAN,30
    7566,JONES,02-APR-81,09:24:10,MANAGER,20
    7654,MARTIN,28-SEP-81,17:24:10,SALESMAN,30my table in database emp2
    create table emp2 (empno number,
                      ename varchar2(20),
                      hiredate date,
                      etime date,
                      ejob varchar2(20),
                      deptno number);the control file code in this path (c:\external\ctrl.ctl)
    load data
    infile 'C:\external\my_data.txt'
    into table emp2
    fields terminated by ','
    (empno, ename, hiredate, etime, ejob, deptno)this is the error :
    C:\>sqlldr scott/tiger control=C:\external\ctrl.ctl
    SQL*Loader: Release 10.2.0.1.0 - Production on Mon May 31 09:45:10 2010
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Commit point reached - logical record count 5
    C:\>any help i greatly appreciated
    thanks
    Edited by: user10947262 on May 31, 2010 9:47 AM

    load data
    infile 'C:\external\my_data.txt'
    into table emp2
    fields terminated by ','
    (empno, ename, hiredate, etime, ejob, deptno)Try
    load data
    infile 'C:\external\my_data.txt'
    into table emp2
    fields terminated by ','
    (empno, ename, hiredate, etime "to_date(:etime,'hh24:mi:ss')", ejob, deptno)
    this is the error :
    C:\>sqlldr scott/tiger control=C:\external\ctrl.ctl
    SQL*Loader: Release 10.2.0.1.0 - Production on Mon May 31 09:45:10 2010
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Commit point reached - logical record count 5
    C:\>
    That's not an error, you can see errors within log and bad files.

  • How to load SQL scripts from a text file.

    Hi, i tried several time to load a text file/SQL script with 10 different tables and data, but 10g Express doesen't allows me to do that, any one can direct me or point out to me what i should do or do i need to adopt any special method to to get this done. i am sure there must be some thing where you can upload SQL scripts from a text file (in SQL command editor!). thanks

    Hi,
    see my other answer here:
    SQL command editor doesn't take more than 1 insert command
    This seems to be a duplicate question, right? Or am I missing something?
    Regards,
    ~Dietmar.

  • Need Help: UTL_FILE Reading and Writing to Text File

    Hello I am using version 11gR2 using the UTL_FILE function to read from a text file then write the lines where it begins with word 'foo' and end my writing to the text file where the line with the word 'ZEN' is found. Now, I have several lines that begin with 'foo' and 'ZEN' Which make for one full paragraph, and in this paragraph there's a line that begins with 'DE4.2'. Therefore,
    I need to write all paragraphs that include the line 'DE4.2' in their beginning and ending lines 'foo' and 'ZEN'
    FOR EXAMPLE:
    FOO/234E53LLID
    THIS IS MY SECOND LINE
    THIS IS MY THIRD LINE
    DE4.2 THIS IS MY FOURTH LINE
    THIS IS MY FIFTH LINE
    ZEN/DING3434343
    FOO/234E53LLID
    THIS IS MY SECOND LINE
    THIS IS MY THIRD LINE
    THIS IS MY FIFTH LINE
    ZEN/DING3434343
    I am only interested in writing the first paragraph tha includes line DE4.2 in one of ther lines Not the Second paragraph that does not include the 'DE4.2'
    Here's my code thus far:
    CREATE OR REPLACE PROCEDURE my_app2 IS
    infile utl_file.file_type;
    outfile utl_file.file_type;
    buffer VARCHAR2(30000);
    b_paragraph_started BOOLEAN := FALSE; -- flag to indicate that required paragraph is started
    BEGIN
    -- open a file to read
    infile := utl_file.fopen('TEST_DIR', 'mytst.txt', 'r');
    -- open a file to write
    outfile := utl_file.fopen('TEST_DIR', 'out.txt', 'w');
    -- check file is opened
    IF utl_file.is_open(infile)
    THEN
    -- loop lines in the file
    LOOP
    BEGIN
    utl_file.get_line(infile, buffer);
         --BEGINPOINT APPLICATION
    IF buffer LIKE 'foo%' THEN
              b_paragraph_started := TRUE;          
         END IF;
         --LOOK FOR GRADS APPS
              IF b_paragraph_started AND buffer LIKE '%DE4%' THEN
              utl_file.put_line(outfile,buffer, FALSE);
    END IF;
         --ENDPOINT APPLICATION      
              IF buffer LIKE 'ZEN%' THEN
         b_paragraph_started := FALSE;
              END IF;
    utl_file.fflush(outfile);
    EXCEPTION
    WHEN no_data_found THEN
    EXIT;
    END;
    END LOOP;
    END IF;
    utl_file.fclose(infile);
    utl_file.fclose(outfile);
    EXCEPTION
    WHEN OTHERS THEN
    raise_application_error(-20099, 'Unknown UTL_FILE Error');
    END my_app2;
    When I run this code I only get one line: DE4.2 I AM MISSING THE ENTIRE PARAGRAPH
    PLEASE ADVISE...

    Hi,
    Look at where you're calling utl_file.put_line. The only time you're writing anything is immediately after you find the the key word 'DE4', and then you're writing just that line.
    You need to store the entire paragraph, and when you reach the end of the paragraph, write the whole thing only if you found the key word, like this:
    CREATE OR REPLACE PROCEDURE my_app2 IS
        TYPE  line_collection  
        IS       TABLE OF VARCHAR2 (30000)
               INDEX BY BINARY_INTEGER;
        infile               utl_file.file_type;
        outfile                      utl_file.file_type;
        input_paragraph          line_collection;
        input_paragraph_cnt          PLS_INTEGER     := 0;          -- Number of lines stored in input_paragraph
        b_paragraph_started      BOOLEAN      := FALSE;     -- flag to indicate that required paragraph is started
        found_key_word          BOOLEAN          := FALSE;     -- Does this paragraph contain the magic word?
    BEGIN
        -- open a file to read
        infile := utl_file.fopen('TEST_DIR', 'mytst.txt', 'r');
        -- open a file to write
        outfile := utl_file.fopen('TEST_DIR', 'out.txt', 'w');
        -- check file is opened
        IF utl_file.is_open(infile)
        THEN
         -- loop lines in the file
         LOOP
             BEGIN
              input_paragraph_cnt := input_paragraph_cnt + 1;
                 utl_file.get_line (infile, input_paragraph (input_paragraph_cnt));
              --BEGINPOINT APPLICATION
              IF LOWER (input_paragraph (input_paragraph_cnt)) LIKE 'foo%' THEN
                  b_paragraph_started := TRUE;
              END IF;
              --LOOK FOR GRADS APPS
              IF b_paragraph_started
              THEN
                  IF  input_paragraph (input_paragraph_cnt) LIKE '%DE4%'
                  THEN
                   found_key_word := TRUE;
                  END IF;
                  --ENDPOINT APPLICATION
                  IF input_paragraph (input_paragraph_cnt) LIKE 'ZEN%' THEN
                      b_paragraph_started := FALSE;
                   IF  found_key_word
                   THEN
                       FOR j IN 1 .. input_paragraph_cnt
                       LOOP
                           utl_file.put_line (outfile, input_paragraph (j), FALSE);
                       END LOOP;
                   END IF;
                   found_key_word := FALSE;
                   input_paragraph_cnt := 0;
                  END IF;
              ELSE     -- paragraph is not started
                  input_paragraph_cnt := 0;
              END IF;
              EXCEPTION
                  WHEN no_data_found THEN
                   EXIT;
              END;
          END LOOP;
        END IF;
        utl_file.fclose (infile);
        utl_file.fclose (outfile);
    --EXCEPTION
    --    WHEN OTHERS THEN
    --        raise_application_error(-20099, 'Unknown UTL_FILE Error');
    END my_app2;
    SHOW ERRORSIf you don't have an EXCEPTION section, the default error handling will print an error message, spcifying exactly what the error was, and which line of your code caused the error. By using your own EXCEPTION section, you're hiding all that information. I admit, the error messages aren't always as informative as we'd like, but they're never less informative than "Unknown UTL_FILE Error'. Don't use your own EXCEPTION handling unless you can improve on the default.
    Remember that anything inside quotes is case-sensitive. If your file contains upper-case 'FOO', then it won't be "LIKE 'foo%' ".
    Edited by: Frank Kulash on Dec 7, 2011 1:35 PM
    You may have noticed that this site normally doesn't display multiple spaces in a row.
    Whenever you post formatted text (such as your code) on this site, type these 6 characters:
    \{code}
    (small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.

  • Output in text file

    Hi
    I have two master & detailed table for eg emp,dept.
    I need my output in text file with delimiter ~ in the below format.
    10~accounting~newyork
    7782~CLARK~MANAGER~7839~6/9/1981~2450.00~10
    7839~KING~PRESIDENT~11/17/1981~5000.00~10
    7934~MILLER~CLERK~7782~1/23/1982~1300.00~10Rgds
    Vk

    well, go for it! Don't let us stop you ;)
    SQL> set colsep '~'
    SQL> select *
      2    from emp
      3  /
         EMPNO~ENAME     ~JOB      ~       MGR~HIREDATE ~       SAL~      COMM~    DEPTNO
    ----------~----------~---------~----------~---------~----------~----------~----------
          7369~SMITH     ~CLERK    ~      7902~17-DEC-80~       800~          ~        20
          7499~ALLEN     ~SALESMAN ~      7698~20-FEB-81~      1600~       300~        30
          7521~WARD      ~SALESMAN ~      7698~22-FEB-81~      1250~       500~        30
          7566~JONES     ~MANAGER  ~      7839~02-APR-81~      2975~          ~        20
          7654~MARTIN    ~SALESMAN ~      7698~28-SEP-81~      1250~      1400~        30
          7698~BLAKE     ~MANAGER  ~      7839~01-MAY-81~      2850~          ~        30
          7782~CLARK     ~MANAGER  ~      7934~09-JUN-81~      2450~          ~        10
          7788~SCOTT     ~ANALYST  ~      7566~19-APR-87~      3000~          ~        20
          7839~KING      ~PRESIDENT~          ~17-NOV-81~      5000~          ~        10
          7844~TURNER    ~SALESMAN ~      7698~08-SEP-81~      1500~         0~        30
          7876~ADAMS     ~CLERK    ~      7788~23-MAY-87~      1100~          ~        20
          7900~JAMES     ~CLERK    ~      7698~03-DEC-81~       950~          ~        30
          7902~FORD      ~ANALYST  ~      7566~03-DEC-81~      3000~          ~        20
          7934~MILLER    ~CLERK    ~      7782~23-JAN-82~      1300~          ~        10
    14 rows selected.

  • Read email adress from a text file then check the validity of them

    a text file has three lines, each line contains one email adress:
    [email protected]
    qwe@@ws.com
    wer//@we.net
    read the email address from a text file, then check which one is invalid, output the invalid email adress in the console.

    no 3 .umm, an email adress can have more than 2 '.'s in it,
    example:
    [email protected]
    would be a valid email address.
    To decide what a valid address is you'd need to parse it against the correct standard.
    I think however that javax.mail.internet.InternetAddress does this for you, check out the docs:
    http://java.sun.com/products/javamail/1.2/docs/javadocs/javax/mail/internet/InternetAddress.html
    even if it parses it may not be a valid address though in that it may not actually exist.

  • How to redirect CELLCLI output to text file

    Hi,
    I would like to redicrect the output of the cellcli command to a text file .
    For example , how to redirect the output of this command to a text file on /tmp
    CellCLI> list metrichistory where objectType = 'CELL' -
    and name = 'CL_TEMP'Thanks

    cellcli has spooling capabilities similar to sqlplus:
    CellCLI> help spool
      Usage:  SPO[OL] [<filename> [ CRE[ATE] | REP[LACE] | APP[END]] | OFF ]
      Purpose: SPOOL <filename>: Direct the results to the file <filename>.
               SPOOL OFF: Turn off the spooling.
               SPOOL: Check the current spooling status.
      Arguments:
        <filename>: The filename where the results will be output.
      Options:
        [APPEND]: If the filename already exists, the following output will
                  be appended to the file. Without this option, the existing file
                  contents will be replaced.
        [CREATE]: If the filename already exists, an error is reported.
        [REPLACE]: If the filename already exists, the contents will be
                  replaced.  This is the default, when no option is provided.
      Examples:
        spool myfile
        spool myfile append
        spool off
        spoolBut if you are trying to script it, it would be easier to just run it command line:
    # cellcli -e "list metrichistory where objectType = 'CELL' and name = 'CL_TEMP'" > /tmp/CL_TEMP.txtAlso look into dcli which allows you to run cellcli commands on one or more cells from a compute node.
    Good luck.

  • Converting Excel Output to Text File (Text(MS-DOS)) in oracle 6i

    I have been able to save Excel Output to Text File (.txt) using OLE. However, I need to save it as TEXT(MS-DOS) specifically due to certain formatting issues.
    Kindly suggest some solution.
    I need it very urgently.
    Thanks!

    Hello Sandy,
    does this mean that you created an Excel file using OLE and named it *.txt?
    And what do you mean by saving as TEXT(MS-DOS)? A csv file?
    Regards
    Marcus

  • My phone keeps saying the storage is full so I deleted pictures, apps, and all my texts. Then after I do this my phone freezes and I have to restart it. When I restart my phone then everything I deleted comes back. What is going on?

    My phone keeps saying the storage is full so I deleted pictures, apps, and all my texts. Then after I do this my phone freezes and I have to restart it. When I restart my phone then everything I deleted comes back. What is going on?

    HI Shelby,
    It sounds like your available free space is not reporting properly. I would start by quitting the Settings app:
    iOS: Force an app to close
    Double-click the Home button.
    Swipe left or right until you have located the app you wish to close.
    Swipe the app up to close it.
    When you have done that restart the device and test the issue again:
    iOS: Turning off and on (restarting) and resetting 
    If the issue persists, backup your device to iTunes, then restore it as new and verify that it works. 
    How to erase your iOS device and then set it up as a new device or restore it from backups
    If it does, then restore your backup to either verify it still works and the software just needed reinstalled, or isolate the issue to the backup file itself. 
    Thank you for using Apple Support Communities.
    Regards,
    Sterling

  • How to add header and fooder in text file

    Hi,
    i have created simple application for generate report from database into text file.
    But i need to add header and fooder in text file. I dont know is there any API for adding these.
    Can anyone help me to create header and fooder in text file.
    the below text are needs to be print in the header
    name of the table :
    Recorder type :
    file creation time:
    the below text are needs to be print in the footer
    Recorder Number:
    Record Type;
    the actual code is
                           pst = con.prepareStatement("select REQUEST, DOMAIN_NAME, TRUNC(DATE_OF_CONFIGURATION) AS dateofConfig  FROM employee where id=300");
                               rs = pst.executeQuery();
                            while (rs.next()) {
                                 request = rs.getString("REQUEST");
                                    domain_name = rs.getString("DOMAIN_NAME");
                                    dateofconfig = rs.getString("dateofConfig");
                                    System.out.println(request + " " + domain_name + " " + dateofconfig);
                                   data.add(request + " " + domain_name + " " + dateofconfig);
                            System.out.println("before calling method");
                            writeToFile(data, "c:/Employee.txt");
                            System.out.println("file created successfull");
                            rs.close();
                            pst.close();
           private static void writeToFile(List list, String path) {
                    BufferedWriter out = null;
                    try {
                            File file = new File(path);
                            out = new BufferedWriter(new FileWriter(file, true));
                            for (Object obj : list) {
                                String s=  obj.toString(); 
                                 out.write(s);
                                    out.newLine();
                            out.close();
                    } catch (IOException e) {
    }Thanks
    Jasmin
    Edited by: user13836688 on Mar 21, 2011 4:06 AM
    Edited by: user13836688 on Mar 21, 2011 4:07 AM
    Edited by: user13836688 on Mar 21, 2011 4:08 AM

    user13836688 wrote:
    i have created simple application for generate report from database into text file.First off, when posting code, use &#91;code]...&#91;/code]. or '' tags, not '<code>'.
    But i need to add header and fooder in text file. I dont know is there any API for adding these.
    Can anyone help me to create header and fooder in text file.Well you plainly have the code to write the file contents; and furthermore your report seems to be contained in a List called 'data'. Why not just add the header and footer lines to it? I'd also suggest making 'data' a LinkedList. That way you can add the header afterwards with no performance hit, just in case the information it contains isn't available at the start of your report loop.
    Winston                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • ALE, IDOC - need to send IDOC and create a text file

    Hi,
    i need to send idoc to some other system and create a text file in that.
    I want sent data to Channel Cluster.
    what are the settings required for that in transactions
    BD54
    SCC4
    SM59 - which connection is required
    WE21 - which type of port
    WE20 - which partner
    BD64
    Is there any other function modules required.
    which function module is suitable like MASTER_IDOC_DISTRIBUTE.

    Hi,
    SM59 - Use TCP/IP Connection with connection type 'T'
    WE20 - Partner Name can be logical system name, if it is a vendor/customer you can configure it under the respective names.
    Thanks
    Krithika

  • "How Display and Output Acq'd File.VI works?"

    "My present project is somewhat similar to Display and Output Acq'd File.vi. But I don't clearly know how it works. My questions are:
    1. What will happen if the data-reading from file is faster than output-generation from buffered data?
    2. How does it match pace of reading and that of generation, and in which vi does the matching achieve?
    3. Is it possible to get these control information, like interrupt or DMA status in labview application?
    Thank you for your help
    Steven"

    I attached a bmp that illustrates how to read and write simultaneously from one file. The VI is using notifiers (under the advanced palette) to synchronize reader and writer loops.
    Note that the Wait function in the reader loop is irrelevant because the Wait on Notifier function blocks until data is available. This forces reader to be at least as slow as writer.
    Attachments:
    read_and_write.bmp ‏1014 KB

Maybe you are looking for