Read last characters from a file

Hey All:
i'm a novice when it comes to powershell- but this is what i'm trying to do.
I have the following command-
gwmi-classwin32_computersystem|selectName|out-filec:\computername.txt
I want to then read the last three characters of the computername from the file. If there is a 'cleaner' approach
please enlighten me.
Thanks for all the help
-Matlock

Hi,
Here's a method you can use:
$name = (Get-WmiObject Win32_ComputerSystem).Name
$shortName = $name.SubString($name.Length - 3)
$shortName
EDIT: Show on the draw, see Tommy's response above.
Don't retire TechNet! -
(Don't give up yet - 12,700+ strong and growing)

Similar Messages

  • Reading Japanese Characters from Properties File

    I am running on Windows 2000 (English). Can any one suggest on how to read Japanese Characters from a ".properties" file.
    TIA

    look at ResourceBundle and unicode encoding,
    Jim

  • XSL-FO unable to read special characters from the XML file

    Team,
    please help on issue, when trying to read the text from XML file (Special characters like bullet). It is displaying as Question mark(?) in output in place of bullet..please proved any soultion.

    The "?" signals a character set mismatch issue - http://www.oracle.com/technetwork/database/globalization/nls-lang-099431.html - between client and database software

  • Does LabView program behave differentl​y under Traditiona​l Chinese version from regular English version. The program reads in numbers and characters from input files.

    Does LabView program behave differently under Traditional Chinese version from regular English version. The program reads in numbers and characters from input files.

    Hope this helps,
    Ankita

  • Reading the data from excel file which is in application server.

    Hi,
    Iam trying to read the data from excel file which is in application server.
    I tried using the function module ALSM_EXCEL_TO_INTERNAL_TABLE. But it didn't work.
    I tried just reading using open data set and read data set it is giving junk characters.
    Please suggest me if you have any solution.
    Best Regards,
    Brahma Reddy

    Hi Narendra,
    Please see the below code I have written
    OPEN DATASET pa_sfile for INPUT in text mode ENCODING  DEFAULT MESSAGE wf_mess.
    CHECK sy-subrc = 0.
    DO.
    READ DATASET pa_sfile INTO wf_string.
    IF sy-subrc <> 0.
    EXIT.
    else.
    split wf_string at wl_# into wf_field1 wf_field2 wa_upload-field3
    wa_upload-field4 wa_upload-field5 wa_upload-field6 wa_upload-field7 wa_upload-field8
    wa_upload-field9 wa_upload-field10 wa_upload-field11 wa_upload-field12 wa_upload-field13
    wa_upload-field14 wa_upload-field15 wa_upload-field16 wa_upload-field17 wa_upload-field18
    wa_upload-field19 wa_upload-field20 wa_upload-field21 wa_upload-field22 wa_upload-field23
    wa_upload-field24 wa_upload-field25 wa_upload-field26 wa_upload-field27 wa_upload-field28
    wa_upload-field29 wa_upload-field30 wa_upload-field31 wa_upload-field32 wa_upload-field33
    wa_upload-field34 wa_upload-field35 wa_upload-field36 .
    wa_upload-field1 = wf_field1.
    wa_upload-field2 = wf_field2.
    append wa_upload to int_upload.
    clear wa_upload.
    ENDIF.
    ENDDO.
    CLOSE DATASET pa_sfile.
    Please note Iam using ECC5.0 and it is not allowing me to declare wl_# as x as in your code.
    Also if Iam using text mode I should use extension encoding etc.( Where as not in your case).
    Please suggest me any other way.
    Thanks for your help,
    Brahma Reddy

  • Reading long text from excel file to an internal table

    Hi
    Can any body tell me how to read long text from excel file to an internal table.
    When i am using this FM KCD_EXCEL_OLE_TO_INT_CONVERT then it is reading only 32 characters from each cell.
    But in my excel sheet in one of the cell has very long text which i need to upload into a internal table.
    may i know which FM or what logic i need to use for this problem.
    Regards

    Hi,
    Here is an example program.  It will upload an Excel file with two columns.  You could also assign the Excel structure dynamically, but I wanted to keep the example simple.  The main point is that the internal table (it_excel in this example) must match the Excel structure that you want to convert.
    Remember, this is just an example to help you figure out how to properly use the technique.  It will certainly need to be modified to fit your requirements, and as always there may be a better way to get the Excel converted... this is just one possibility that has worked for me in the past.
    *& Report  zexcel_upload_test                            *
    REPORT  zexcel_upload_test.
    TYPE-POOLS: truxs.
    TYPES: BEGIN OF ty_excel,
             col_a(10) TYPE n,
             col_b(35) TYPE c,
           END OF ty_excel.
    DATA: l_data_tab         TYPE TABLE OF string,
          l_text_data        TYPE truxs_t_text_data,
          l_gui_filename     TYPE string,
          it_excel           TYPE TABLE OF ty_excel.
    FIELD-SYMBOLS: <wa_excel>  TYPE ty_excel.
    PARAMETERS: p_file TYPE rlgrap-filename.
    * Pass the file name in the correct format
    l_gui_filename = p_file.
    * Upload data from PC
    CALL METHOD cl_gui_frontend_services=>gui_upload
      EXPORTING
        filename                = l_gui_filename
        filetype                = 'ASC'
        has_field_separator     = 'X'
      CHANGING
        data_tab                = l_data_tab
      EXCEPTIONS
        file_open_error         = 1
        file_read_error         = 2
        no_batch                = 3
        gui_refuse_filetransfer = 4
        invalid_type            = 5
        no_authority            = 6
        unknown_error           = 7
        bad_data_format         = 8
        header_not_allowed      = 9
        separator_not_allowed   = 10
        header_too_long         = 11
        unknown_dp_error        = 12
        access_denied           = 13
        dp_out_of_memory        = 14
        disk_full               = 15
        dp_timeout              = 16
        OTHERS                  = 17.
    IF sy-subrc <> 0.
    *   MESSAGE ...
      EXIT.
    ENDIF.
    * Convert from Excel into the appropriate itab
    l_text_data[] = l_data_tab[].
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
      EXPORTING
        i_field_seperator    = 'X'
        i_tab_raw_data       = l_text_data
        i_filename           = p_file
      TABLES
        i_tab_converted_data = it_excel
      EXCEPTIONS
        conversion_failed    = 1
        OTHERS               = 2.
    IF sy-subrc <> 0.
    *   MESSAGE ...
      EXIT.
    ENDIF.
    LOOP AT it_excel ASSIGNING <wa_excel>.
    *  Do something here...
    ENDLOOP.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      PERFORM filename_get CHANGING p_file.
    *       FORM filename_get                                             *
    FORM filename_get CHANGING p_in_file TYPE rlgrap-filename.
      DATA: l_in_file  TYPE string,
            l_filetab  TYPE filetable,
            wa_filetab TYPE LINE OF filetable,
            l_rc       TYPE i,
            l_action   TYPE i,
            l_init_dir TYPE string.
    * Set the initial directory to whatever you want it to be
      l_init_dir = 'C:\'.
    * Call the file open dialog without multiselect
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        EXPORTING
          window_title            = 'Load file'
          default_extension       = '.XLS'
          default_filename        = l_in_file
          initial_directory       = l_init_dir
          multiselection          = 'X'
        CHANGING
          file_table              = l_filetab
          rc                      = l_rc
          user_action             = l_action
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          OTHERS                  = 4.
      IF sy-subrc <> 0.
        REFRESH l_filetab.
      ENDIF.
    * Read the selected filename
      READ TABLE l_filetab INTO wa_filetab INDEX 1.
      IF sy-subrc = 0.
        p_in_file = wa_filetab-filename.
      ENDIF.
    ENDFORM.                    " filename_get
    Regards,
    Jamie

  • Save last path from webutil file dialog

    Hello!
    Is it possible, or how is it possible to save every client's "last path" from choosing files with webutil?
    When we used forms 6, the standard Windows file dialog appeared and it's saving the last path where a file was choosen. With the "new" webutil filedialog this behavior changed and it always opens at the "initial" directory.
    Is there any solution to this?
    Thanks in advance for help

    If you are using the WebUtil_File.File_Open_Dialog() function, you can specify the directory_name as a parameter. When you open a file for the first time in your form, just capture the directory location to a variable and pass this in subsequent calls. Unfortunately, since your form is now Web Deployed, Forms uses Java to display a File Open Dialog so it doesn't retail the last location opened.
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Tomcat unable to read accented characters from MySQL

    Folks,
    Can anyone help with me this problem?
    It seems that my version of Tomcat is unable to read accented characters from my MySQL Database.
    I've checked in the Database and the characters are all correctly represented there. But when, in my servlet code, I do:
    String author = results.getString("author_surname");If the String contains any accented character then the character shows as a '?'. (Even before it gets to the JSP - I'm writing the results straight to catalina.out).
    Looking around these forums I found that some people suggested adding
    ?useUnicode=TRUE&characterEncoding=UTF-8;to the end of my jdbc url. As in:
    <ResourceParams name="jdbc/connection">
    //a whole load of other params
      <parameter>
        <name>url</name>
         <value>jdbc:mysql://localhost:3306/bookshop?useUnicode=TRUE&characterEncoding=UTF-8</value>
      </parameter>
    </ResourceParams>inside my server.xml
    But it doesn't seem to make any difference. In addition, I doubt I even need to use Unicode as the accents I need are only: ����� etc.
    (Incidentally, writing that line into my server.xml, tomcat complains that it should finish with a semi-colon. Is that correct? Even if I put in the semi-colon, it still complains!!)
    Any suggestions on this would be much appreciated. Thank you.

    user13109986 wrote:
    HI,
    From http://download.oracle.com/docs/cd/B10501_01/server.920/a96529/ch9.htm
    My understanding is the JDBC Api converts the string from the database to UTF-16.. If so is there any way to disable the UTF-16 encoding at JDBC API?That's exactly what it's supposed to do. There isn't even any concept of what it would mean to disable that: Java characters are UTF-16 representations of Unicode code-points, so there isn't anything else it could do.
    I still suspect the JDBC part is working correctly and your writing-to-file isn't. I found this quote in the Wikipedia article on Windows-1256:
    Windows-1256 is a code page used to write Arabic (and possibly some other languages that use Arabic script, like Persian) under Microsoft Windows. This code page is not compatible with ISO 8859-6 and MacArabic encodings.So was there a particular reason you chose Cp1256 and not ISO-8859-6 as the charset to write to the file with?

  • How to read the data from Excel file and Store in XML file using java

    Hi All,
    I got a problem with Excel file.
    My problem is how to read the data from Excel file and Store in XML file using java excel api.
    For getting the data from Excel file what are all the steps i need to follow to get the correct result.
    Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
    Thanks & Regards,
    Sreenu,
    [email protected],
    india,

    If you want someone to do your work, please have the courtesy to provide payment.
    http://www.rentacoder.com

  • How can I input read a line from a file and output it into the screen?

    How can I input read a line from a file and output it into the screen?
    If I have a file contains html code and I only want the URL, for example, www24.brinkster.com how can I read that into the buffer and write the output into the screen that using Java?
    Any help will be appreciate!
    ======START FILE default.html ========
    <html>
    <body>
    <br><br>
    <center>
    <font size=4 face=arial color=#336699>
    <b>Welcome to a DerekTran's Website!</b><br>
    Underconstructions.... <br>
    </font> </center>
    <font size=3 face=arial color=black> <br>
    Hello,<br>
    <br>
    I've been using the PWS to run the website on NT workstation 4.0. It was working
    fine. <br>
    The URL should be as below: <br>
    http://127.0.0.1/index.htm or http://localhost/index.htm
    <p>And suddently, it stops working, it can't find the connection. I tried to figure
    out what's going on, but still <font color="#FF0000">NO CLUES</font>. Does anyone
    know what's going on? Please see the link for more.... I believe that I setup
    everything correctly and the bugs still flying in the server.... <br>
    Thank you for your help.</P>
    </font>
    <p><font size=3 face=arial color=black>PeerWebServer.doc
    <br>
    <p><font size=3 face=arial color=black>CannotFindServer.doc
    <br>
    <p><font size=3 face=arial color=black>HOSTS file is not found
    <br>
    <p><font size=3 face=arial color=black>LMHOSTS file
    <br>
    <p><font size=3 face=arial color=black>How to Setup PWS on NT
    <BR>
    <p><font size=3 face=arial color=black>Issdmin doc</BR>
    Please be patient while the document is download....</font>
    <font size=3 face=arial color=black><br>If you have any ideas please drop me a
    few words at [email protected] </font><br>
    <br>
    <br>
    </p>
    <p><!--#include file="Hits.asp"--> </p>
    </body>
    </html>
    ========= END OF FILE ===============

    Hi!
    This is a possible solution to your problem.
    import java.io.*;
    class AddressExtractor {
         public static void main(String args[]) throws IOException{
              //retrieve the commandline parameters
              String fileName = "default.html";
              if (args.length != 0)      fileName =args[0];
               else {
                   System.out.println("Usage : java AddressExtractor <htmlfile>");
                   System.exit(0);
              BufferedReader in = new BufferedReader(new FileReader(new File(fileName)));
              StreamTokenizer st = new StreamTokenizer(in);
              st.lowerCaseMode(true);
              st.wordChars('/','/'); //include '/' chars as part of token
              st.wordChars(':',':'); //include ':' chars as part of token
              st.quoteChar('\"'); //set the " quote char
              int i;
              while (st.ttype != StreamTokenizer.TT_EOF) {
                   i = st.nextToken();
                   if (st.ttype == StreamTokenizer.TT_WORD) {          
                        if (st.sval.equals("href")) {               
                             i = st.nextToken(); //the next token (assumed) is the  '=' sign
                             i = st.nextToken(); //then after it is the href value.               
                             getURL(st.sval); //retrieve address
              in.close();
         static void getURL(String s) {     
              //Check string if it has http:// and truncate if it does
              if (s.indexOf("http://") >  -1) {
                   s = s.substring(s.indexOf("http://") + 7, s.length());
              //check if not mailto: do not print otherwise
              if (s.indexOf("mailto:") != -1) return;
              //printout anything after http:// and the next '/'
              //if no '/' then print all
                   if (s.indexOf('/') > -1) {
                        System.out.println(s.substring(0, s.indexOf('/')));
                   } else System.out.println(s);
    }Hope this helps. I used static methods instead of encapsulating everyting into a class.

  • Regarding reading the data from the files without using Stremas

    hai to all of u...
    here i have a problem where i have to read the data from the files without using any streams.
    please guide me how to do this one,if possible by giving with an example
    Thanks & Regard
    M.Ramakrishna

    Simply put, you can't.
    By why do you need to?

  • How to read the data from a file in another computer with user name and password login

    How to read read the data from a file in anohter computer which need to login with user name and password?

    duplicate post:  http://forums.ni.com/t5/LabVIEW/log-on-the-other-computer-with-user-name-and-password/m-p/2061478
    duplicate post:  http://forums.ni.com/t5/LabVIEW/do-need-to-enter-the-user-name-and-password-when-TCP-ip/m-p/2061612
    duplicate post   http://forums.ni.com/t5/LabVIEW/log-on-the-other-computer-with-user-name-and-password/m-p/2060682

  • How to read and write from XL file

    HI ,
    I wanted to read a data from XL file and write a data in XL file by generating a report .Can any body help me out.Many examples are available on discussion forums but when I try to save and run those Vi .I am not able to run Showing error .Please tell what is going wrong as I m having latest labview 8.6 .
    Regards
    Sharmila.karale

    Hi Adnan,
    Here are the examples of Vi which I have downloaded from the forum for my reference
    Regards
    Sharmila.Krale
    Attachments:
    SAVE TO EXCEL.llb ‏128 KB
    excel.llb ‏1618 KB

  • Reading Sheet name from csv file.

    Dear All,
    I am doing one program where i am reading contents from .csv file from oracle forms. I m using utl_file for reading the contents from .csv file.
    But problem is i am having 5 sheets under .csv file and i want to read fifth sheet's data. how do i jump to particular sheet in csv file. please help me in this case. this is very urgent.
    regards,
    Manish n

    I'm not sure of the format of a CSV with sheets : I assume it's a spreadsheet with multiple sheets ?
    I know that using Apache POI you can read (and write) native XLS or XLSX spreadsheets and then iterate through the sheets / rows cells. This requires java knowledge but works really well.
    Steve

  • Code for reading particular  fields from the file placed in application

    hi,
    code for reading particular  fields from the file placed in application server in to the internal table.

    Hi,
    Use the GUI_UPLOAD FM to upload the File into ur Internal Table.
    DATA : FILE_TABLE TYPE FILE_TABLE OCCURS 0,
             fwa TYPE FILE_TABLE,
             FILENAME TYPE STRING,
             RC TYPE I.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
      EXPORTING
        WINDOW_TITLE            = 'Open File'
       DEFAULT_EXTENSION       =
       DEFAULT_FILENAME        =
       FILE_FILTER             =
       INITIAL_DIRECTORY       =
       MULTISELECTION          =
       WITH_ENCODING           =
      CHANGING
        FILE_TABLE              = FILE_TABLE
        RC                      = RC
       USER_ACTION             =
       FILE_ENCODING           =
      EXCEPTIONS
        FILE_OPEN_DIALOG_FAILED = 1
        CNTL_ERROR              = 2
        ERROR_NO_GUI            = 3
        NOT_SUPPORTED_BY_GUI    = 4
        others                  = 5
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    READ TABLE FILE_TABLE INDEX 1 into fwa.
    FILENAME = fwa-FILENAME.
        CALL FUNCTION 'GUI_UPLOAD'
             EXPORTING
                  filename                = filename
                  FILETYPE                = 'DAT'
           IMPORTING
                FILELENGTH              =
             TABLES
                  data_tab                = itab
             EXCEPTIONS
                  file_open_error         = 1
                  file_read_error         = 2
                  no_batch                = 3
                  gui_refuse_filetransfer = 4
                  invalid_type            = 5
                  OTHERS                  = 6 .
        IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    Regards,
    Balakumar.G
    Reward Points if helpful.

Maybe you are looking for

  • Cookie based Load Balancing

    If 3 Real servers in a non-load balancing environmet are setting session cookies with diffrenet cookie names e.g. server1 response set-Cookie: SESSIDSAAAAAA=DMNNNELCECNCKDIIDCPOIMGG Server2 response set-Cookie: SESSIDSBBBBBB=DAAMMNELCECNCKPYTWPOIPOP

  • Redacted file size

    I just completed some redactions using Acrobat Pro X and the file size went from 65k to 1.5mb.  I used the Save As... Reduced File Size PDF and that brought the file size down to 1mb.  It seems to me that redaction shouldn't result in such a huge inc

  • Download EhP4 packages for ECC 6.0 including EhP1 for NW 7.0

    Hi experts, I have the following problem. I must update an existing ECC 6.0 system to NW EhP1. I found it is not possible to update only the NetWeaver but the whole ERP 6.0 must be updated to EhP4. The system is registered in Sol. Man. as ECC with no

  • How to use Console to find Trash commands?

    I know Console is powerful, but I don't know exactly which log on the left-hand side bar to select to look for trash "entries". I need to run a search in Console to discover if/when large movie files would have been deleted (moved into Trash) and a s

  • Mouse speeds up when iMac is shut off.

    I slow the mouse speed way down because of my tremors. Every time I shut the iMac down and restart I get a speedy mouse at start up. I have to go into the mouse prefs to slow it down. Why will it not stay where I set it? I'm probably missing a simple