Passing tab char in command line

Discussion in 'Java' started by alejandrina, May 31, 2006.

  1. alejandrina

    alejandrina Guest

    Hi all,

    I want to pass a tab character as a command line parameter. Ihave this
    statement to extract a char from the string:

    char delim = args[0].charAt(0);

    The problem is how do you write the command line? I've tried all of
    these:

    java testTab "\t"
    java testTab "\\t"
    java testTab \t
    java testTab \\t
    java testTab "\u0009"
    java testTab \u0009

    none work. "delim" above never gets the right character. Interestingly,
    when I submit

    java testTab "\u0009" or
    java testTab "\\t"


    args[0] contains a string of length = 2, the first character being "\"
    and the second is the tab. Obviously, the parser feels the need to
    "escape" my backslash character. How do you disable this behavior?

    Thanks!

    Alejandrina
    alejandrina, May 31, 2006
    #1
    1. Advertising

  2. alejandrina

    Oliver Wong Guest

    "alejandrina" <> wrote in message
    news:...
    > Hi all,
    >
    > I want to pass a tab character as a command line parameter. Ihave this
    > statement to extract a char from the string:
    >
    > char delim = args[0].charAt(0);
    >
    > The problem is how do you write the command line? I've tried all of
    > these:
    >
    > java testTab "\t"
    > java testTab "\\t"
    > java testTab \t
    > java testTab \\t
    > java testTab "\u0009"
    > java testTab \u0009
    >
    > none work. "delim" above never gets the right character. Interestingly,
    > when I submit
    >
    > java testTab "\u0009" or
    > java testTab "\\t"
    >
    >
    > args[0] contains a string of length = 2, the first character being "\"
    > and the second is the tab. Obviously, the parser feels the need to
    > "escape" my backslash character. How do you disable this behavior?


    When you type things "at the command line", you're actually giving input
    to a program which is typically called a "shell". On Windows XP, for
    example, most people use the shell known as "cmd.exe". On Linux, it might be
    bash, or csh or some other shell.

    Each shell has its own rules about what escaping and/or processing it
    does on the input.

    Obviously, the shell you're using chooses not to replace \t with a tab
    character, though it does seem to be replacine two-character substring "\\"
    with the single character substring "\".

    Read the documentation for your shell to find out what escaping
    facilities it provides, and how you can coax it into invoke the java program
    with the tab as one of the parameters.

    - Oliver
    Oliver Wong, May 31, 2006
    #2
    1. Advertising

  3. "Oliver Wong" <> wrote in message
    news:cskfg.235$I61.27@clgrps13...
    >
    > "alejandrina" <> wrote in message
    > news:...
    >> Hi all,
    >>
    >> I want to pass a tab character as a command line parameter. Ihave this
    >> statement to extract a char from the string:
    >>
    >> char delim = args[0].charAt(0);
    >>
    >> The problem is how do you write the command line? I've tried all of
    >> these:
    >>
    >> java testTab "\t"
    >> java testTab "\\t"
    >> java testTab \t
    >> java testTab \\t
    >> java testTab "\u0009"
    >> java testTab \u0009
    >>
    >> none work. "delim" above never gets the right character. Interestingly,
    >> when I submit
    >>
    >> java testTab "\u0009" or
    >> java testTab "\\t"
    >>
    >>
    >> args[0] contains a string of length = 2, the first character being "\"
    >> and the second is the tab. Obviously, the parser feels the need to
    >> "escape" my backslash character. How do you disable this behavior?

    >
    > When you type things "at the command line", you're actually giving
    > input to a program which is typically called a "shell". On Windows XP, for
    > example, most people use the shell known as "cmd.exe". On Linux, it might
    > be bash, or csh or some other shell.
    >
    > Each shell has its own rules about what escaping and/or processing it
    > does on the input.
    >
    > Obviously, the shell you're using chooses not to replace \t with a tab
    > character, though it does seem to be replacine two-character substring
    > "\\" with the single character substring "\".
    >
    > Read the documentation for your shell to find out what escaping
    > facilities it provides, and how you can coax it into invoke the java
    > program with the tab as one of the parameters.
    >
    > - Oliver

    And you might even try typing a double-quote,
    followed by typing the tab key, and another double quote.
    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Software Reuse Project
    Fred Kleinschmidt, May 31, 2006
    #3
  4. alejandrina

    Rhino Guest

    "alejandrina" <> wrote in message
    news:...
    > Hi all,
    >
    > I want to pass a tab character as a command line parameter. Ihave this
    > statement to extract a char from the string:
    >
    > char delim = args[0].charAt(0);
    >
    > The problem is how do you write the command line? I've tried all of
    > these:
    >
    > java testTab "\t"
    > java testTab "\\t"
    > java testTab \t
    > java testTab \\t
    > java testTab "\u0009"
    > java testTab \u0009
    >
    > none work. "delim" above never gets the right character. Interestingly,
    > when I submit
    >
    > java testTab "\u0009" or
    > java testTab "\\t"
    >
    >
    > args[0] contains a string of length = 2, the first character being "\"
    > and the second is the tab. Obviously, the parser feels the need to
    > "escape" my backslash character. How do you disable this behavior?
    >
    > Thanks!
    >

    Have you tried hitting the Tab key rather than typing backslashes and the
    't' character?

    --
    Rhino
    Rhino, May 31, 2006
    #4
  5. alejandrina

    Guest

    As Oliver mentioned the shell(cmd,sh,bash,ksh) is responsible for
    escape processing of command line parameters. You could pass tab by
    typing "(double quote) followed by tab key followed by "(double
    quote).
    In some shells(like cmd, bash) when you type TAB key they provide
    command completion feature, if you type TAB once it fills with file
    name. This should be disabled to pass just TAB character to the
    application. For Windows, you could disable file and directory
    completion by passing /F:OFF switch to cmd(cmd /F:OFF)or by updating
    registry(more info at http://www.computerhope.com/cmd.htm).

    -Rao

    alejandrina wrote:
    > Hi all,
    >
    > I want to pass a tab character as a command line parameter. Ihave this
    > statement to extract a char from the string:
    >
    > char delim = args[0].charAt(0);
    >
    > The problem is how do you write the command line? I've tried all of
    > these:
    >
    > java testTab "\t"
    > java testTab "\\t"
    > java testTab \t
    > java testTab \\t
    > java testTab "\u0009"
    > java testTab \u0009
    >
    > none work. "delim" above never gets the right character. Interestingly,
    > when I submit
    >
    > java testTab "\u0009" or
    > java testTab "\\t"
    >
    >
    > args[0] contains a string of length = 2, the first character being "\"
    > and the second is the tab. Obviously, the parser feels the need to
    > "escape" my backslash character. How do you disable this behavior?
    >
    > Thanks!
    >
    > Alejandrina
    , May 31, 2006
    #5
  6. alejandrina wrote:
    > Hi all,
    >
    > I want to pass a tab character as a command line parameter. Ihave this
    > statement to extract a char from the string:
    >
    > char delim = args[0].charAt(0);
    >
    > The problem is how do you write the command line? I've tried all of
    > these:
    >
    > java testTab "\t"
    > java testTab "\\t"
    > java testTab \t
    > java testTab \\t
    > java testTab "\u0009"
    > java testTab \u0009
    >
    > none work. "delim" above never gets the right character. Interestingly,
    > when I submit
    >
    > java testTab "\u0009" or
    > java testTab "\\t"
    >
    >
    > args[0] contains a string of length = 2, the first character being "\"
    > and the second is the tab. Obviously, the parser feels the need to
    > "escape" my backslash character. How do you disable this behavior?


    <insert what everyone else said about shells />

    If the shell doesn't do the kind of character substitution you want, the
    testTab.main (should that be TestTab?) routine could check for sequences
    like \t and interpret them itself.
    Jeffrey Schwab, Jun 1, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wwj
    Replies:
    7
    Views:
    542
  2. wwj
    Replies:
    24
    Views:
    2,484
    Mike Wahler
    Nov 7, 2003
  3. Ben Pfaff
    Replies:
    5
    Views:
    462
    Tristan Miller
    Jan 17, 2004
  4. Steffen Fiksdal

    void*, char*, unsigned char*, signed char*

    Steffen Fiksdal, May 8, 2005, in forum: C Programming
    Replies:
    1
    Views:
    571
    Jack Klein
    May 9, 2005
  5. lovecreatesbeauty
    Replies:
    1
    Views:
    1,015
    Ian Collins
    May 9, 2006
Loading...

Share This Page