Unix shell isn't respecting my quotes around arguments

When I run a program test in unix, I type in the shell:
shell> java test "arg1 arg2 arg3" arg4
My program should now have two arguments
arg1 arg2 arg3
...and
arg4
Instead it has 4 arguments
arg1
arg2
arg3
arg4
I tried single quotes and everything. Do you have any ideas?

Quite.
For example:
public class Args {
   public static void main(String[] args) {
      System.out.println(args.length + " arguments received:");
      for( String s : args ) {
         System.out.println(s);
}Input:
java Args "arg1 arg2 arg3" arg4
Output:
2 arguments received:
arg1 arg2 arg3
arg4
(edit) That's running under the Bourne Again Shell (bash) on Linux.

Similar Messages

  • Unix shell script to do a cold backup

    i want to do a coldback using a unix shell script.
    the db capacity is around 12 Tb
    wen the backup is done i need to zip it too.at this moment i dont want to copy to the disk.
    kindly help me regarding this
    thanks in advance
    NK

    i used something like this until recently:
    #!/bin/bash
    umask 0077
    export ORACLE_HOME="/u01/app/oracle/product/10.2.0/webdb1"
    export PATH="$ORACLE_HOME/bin:$PATH"
    export NLS_LANG="AMERICAN_AMERICA.WE8ISO8859P1"
    db="dbname"
    pipe="export.pipe"
    file="$db-`date "+%Y-%m-%d"`.dmp"
    if [ ! -p $pipe ]; then
    ## could exist but not be a pipe
    rm -f $pipe
    mknod $pipe p || (echo "could not create pipe $pipe"; exit 1)
    fi
    gzip -c > $file.gz < $pipe &
    exp system/****@$db FULL=Y CONSISTENT=Y FILE=$pipe DIRECT=Y GRANTS=Y
    you could of course also use zip|bzip2|pbzip2 or whatever.
    hth, rgds, armin walland

  • Accessing values between unix shell and WLST

    Hi,
    I am calling WLST script from a Unix shell script. I am passing some arguments to the WLST script. Upon error condition in WLST I am exiting from the WLST. But I want to capture that error condition in the shell script as well and exit from the unix script. Is this possible to achieve. Any lights out appreciated.
    -Gopal

    You can use the native Python exit with a numeric return code. I believe that's system.exit(1) for example, to return 1 to the shell.

  • Is it possible to add a new note on stickies.app by terminal/unix shell scripts ?

    is it possible to add a new note on stickies.app by terminal/unix shell scripts ?

    1. If i uninstall GNU Classpath, Does it cause system not to work properly? Not in my experience. I have encountered dozens of cases where it cured problems like this immediately. Alternatively adjust your PATH so that it finds the JDK before it finds GNU CLASSPATH.
    (Now i am using that java on my server with a certificate , I dont want to risk the system. )GNU CLASSPATH is the risk here.
    2. I have searched about your advice, this link tells classpath causes: "certificate insert problems"
    http://builder.classpath.org/japi/jdk15-classpath.html is this what you mean ?
    I can't find that statement on that page, but it does show compliance problems of up to 20% in the security area (and *40%* in LDAP, the area I'm working in at the moment).
    Basically GNU CLASSPATH is not Java and cannot be expected to behave like it. In this case it doesn't even understand the format of a Java keystore. QED.
    Note that they don't call it 'Java', because it isn't. I quote:
    GNU Classpath 1.0 will be fully compatible with the 1.1 and 1.2 API specifications, in addition to having significant (>95%) compatability with the 1.3, 1.4, 1.5 and 1.6 APIs.In other words they haven't even finished JDK 1.1 yet, let alone all the other stuff. At the present rate of progress they never will. That statement is the latest, it is dated 7 July 2009, and the latest actual software is dated 5 February 2009. And there is clearly no intention of ever submitting it to the Java Compatibility Tests as real Java implementors do.
    3. How can i uninstall GNU Class Path without causing any problems to my working server?No idea, can't help you. Ask a Liinux expert.
    4. Is there any way to add the certificate without removing GNU CLASSPATH ?Yes, see above, but I still strongly recommend removal.

  • Need Help in creating Unix Shell Script for database

    Would be appreciable if some one can help in creating unix shell script for the Oracle DB 10,11g.
    Here is the condition which i want to implement.
    1. Create shell script to create the database with 10GB TB SPACE and 3 groups of redo log file(Each 300MB).
    2. Increase size of redolog file.
    3. Load sample schema.
    4. dump the schema.
    5. Create empty db (Script should check if db already exists and drop it in this case).
    6. Create backup using rman.
    7. restore backup which you have backed up.

    This isn't much of a "code-sharing" site but a "knowledge-sharing" site.  Code posted me may be from a questioner who has a problem / issue / error with his code.   But we don't generally see people writing entire scripts as responses to such questions as yours.  There may be other sites where you can get coding done "for free".
    What you could do is to write some of the code and test it and, if and when it fails / errors, post it for members to make suggestions.
    But the expectation here is for you to write your own code.
    Hemant K Chitale

  • Reg: UNIX shell script at File Adapter

    Hi all,
    I am doing a File to file scenario and using command line arguments in Sending file adapter. I am using UNIX shell script ".sh" file for executing the command.
    I gave the following path at "Run OS command before message processing" parameter:
    /temp/xidelivery/send/FILOSC004_shell.sh
    and this file contains following code:
    <b>#!/user/bin/sh cp /temp/xidelivery/send/FILOSC004_in.txt /temp/xidelivery/send/FILOSC004_input_copy4.txt</b>
    I put the source file, FILOSC004_in.txt and shell script files at the respective paths.
    If I give "cp" command directly in command line it is working fine. But I could not execute this with shell script. Can any body give me the reason where I gone wrong.
    Regards,
    Pavani.

    Hi,
    can you try this,
    bash /temp/xidelivery/send/FILOSC004_shell.sh
    let me know.
    hey you can check the blog below to catch the OS errors,
    /people/michal.krawczyk2/blog/2005/08/17/xi-operation-system-command--error-catching
    Prasad Babu.
    Message was edited by:
            PrasadBabu Koribilli

  • Exit status running java classpath in a unix shell script

    I'm new to putting java into unix scripts. I have a java classpath running inside of a unix shell script. During my testing it will error with java.io.FileNotFoundException error, which I know why that is, but when I set in my unix shell script this to see the right exit status of success/fail, it always shows a 0 for success when that isn't really the case. Below is the two lines I have set to capture the exit status and just display that exit status for now.
    notifycode=$?
    echo $notifycode
    I have these 2 lines above on a line right below my java command in my unix shell script. How can I get my unix shell script to show the right exit status if the java classpath command fails? Thanks for any help.

    That's Java code, it says "End this Java application and send return code 1 back to the shell". As for how the shell gets the return code from the application, that's a question about your shell and not about Java programming, no?

  • Read a Unix Shell Variable

    I need to write some code (i was told its only like 5 lines) that reads the value of a Unix Shell Variable. I searched the forums and found only 1 post on this subject:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=397213
    I'm not sure if this is what i want to do however. my bosses co-worker, told me that i will need to use "System.properties" (i know there is no method System.properites but that is what he said) I looked into System.getProperites, and it just didn't make sence to me why i would be needing anything related to "System.properties". any suggestions on how to do this? (is it really only like 5 lines of code or is it much more complicated than that)
    Nick

    I did a google and found this immediately:
    http://www.javaworld.com/javaworld/javaqa/2001-07/01-qa-0706-env.html
    Google is your friend.
    It also returned a page expanding on the suggestion at the end of that article (using env), but rather than writing it to a file, using Runtime.exec to get an input stream and then sending that to java.util.Properties,
    which isn't a portable solution but doesn't require changing the invocation of the JVM.

  • Unix Shell + forms 4.5

    Hi all,
    How can I call a UNIX shell program (e.g., x.sh) from forms 4.5
    Thank you in advance
    Regards
    Omran

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Anton Weindl ([email protected]):
    You can either use rsh or rexec (both available on windows). You will have to edit the .rhosts in the home directory of the unix user the script will be run under:
    <Client-Hostname> <USER>
    <USER> must match the Windows-User exactly.
    You can then execute the Shell-Script with
    host('rsh <HOST> -l <USER> sh <SCRIPT>',NO_SCREEN)
    Hope that helps
    Anton Weindl
    <HR></BLOCKQUOTE>
    Thank You Anton Weindl,
    It seems like the thing I want to use instead of the dbms_pipe.
    I tried to use rsh and gives me the following message
    command: "rsh taurus -l nileshs test.sh"
    where taurus is hostname and
    guest is unix username
    I am logged on windows 2000 with this name.
    "taurus permission denied:"
    "rsh can't establish connection"
    Let me know if I am missing anything.
    Thanks.
    null

  • Fscript, fscripter and the unix shell

    I am starting to play with Fscript and have yet to decide if I hate it. One thing I would like to be able to do is embed Fscripts within unix shell scripts. Anyone know how to do this?
    I can write an fscript script invoking with
    #!/usr/local/bin/fscripter
    and it runs ok, but the example I am using, a currency converter, won't take input in its dialog boxes. (It works fine from Fscript's own interpreter). So maybe this idea isn't a good one to pursue, but I have been trying to embed fscript within a unix shell script using the usual Here Document formalism, and it doesn't work, at least in my hands.
    Anyone have this working?

    Well? Out with it!

  • Running stored procedure from unix shell

    Hi
    I have a stored procedure proc1 stored in a file, code1.txt in my home directory /home/user. How do i execute this file which contains the stored procedure from unix shell? I would really appreciate it if somebody gives me the complete shell script to accomplish the above task.
    Thanks.

    To put everything together into a single posting:
    The EXEC command is a SQL*Plus macro command. It is not a SQL or PL/SQL command.
    The only way to execute a stored proc from a client, is to wrap the call in an anonymous PL/SQL block. I.e you need a BEGIN and END PL/SQL wrapper around the call.
    E.g.BEGIN
      -- calling a stored proc to start leave processing
      scott.StartLeaveProcessing;
    END;The EXEC macro in SQL*Plus does this automatically for you. Thus less typing. But do not confuse this command with the PL/SQL language.
    Second issue. Use bind variables when making calls from clients. And not just for SQL statements, but also for PL/SQL. Unfortuantely this tends to be a hack in SQL*Plus due to the way SQL*Plus itself treats its bind variable assignments. But in principle, this is what you should do when calling an Oracle stored proc from a client:
    SQL> -- define a host variable
    SQL> var EMPID varchar2(100)
    SQL> var FROM_DEPT number
    SQL> var TO_DEDPT number;
    SQL>
    SQL> -- assign values to these (this is where SQL*Plus hacks it)
    SQL> exec :EMPID := 100;
    SQL> exec :FROM_DEPT := 1;
    SQL> exec :TO_DEPT := 2;
    SQL>
    SQL> -- now make the stored proc call for moving employee 100 from
    SQL> -- department 1 to department 2
    SQL> EXEC scott.EmployeeTransfer( :EMPID, :FROM_DEPT, :TO_DEPT );
    SQL>To do this from a Unix shell script:
    #!/bin/bash
    # environment variables
    # --> put environment such as ORACLE_HOME, ORACLE_SID, TWO_TASK
    # etc. here <--
    # redirect STDIN from TTY (keyboard typewriter device) to the input from
    # this file - which means SQL*Plus will not read from the keyboard but read
    # from this file its input until the EOF marker/text is encountered
    sqlplus -s /nolog << EOF
    connect scott/tiger
    var EMPID varchar2(100)
    var FROM_DEPT number
    var TO_DEDPT number;
    exec :EMPID := 100;
    exec :FROM_DEPT := 1;
    exec :TO_DEPT := 2;
    exec scott.EmployeeTransfer( :EMPID, :FROM_DEPT, :TO_DEPT );
    exit;
    EOF
    #eof

  • Opening a UNIX shell in Java

    Hi,
    I need to simulate the machine's native shell (e.g. cmd\sh in case of windows\unix respectively). For that I open up a UNIX shell in my Java program using the usual manner:
    Runtime.getRuntime().exec("sh");Then I use the input and output streams of the Process in order to "communicate" with the process.
    My code works fine with windows shell ('cmd') but with unix ('sh') I failed to retrieve the machine's prompt. I believe that the issue is unix-related and that the process I launched has no appropriate environment parameter.
    Any idea?
    Thanks in advance

    Thanks for your fast reply.
    Although the article was interesting and did review the java.lang.Runtime quite good, it didn't help me as I have a specific problem with Unix OS and the article deliberately (or not) ignored that.
    I noticed that when I print the environments variables in my java application I get a partial list which doesn't contain the prompt (for instance the SP1 variable) whilst execute the 'set' command (not from java) i get a longer list and the prompt variable appears there.
    Any idea how should I execute the shell through java in order to receive the prompt?

  • Pass commands to UNIX shell opened in Windows XP OS

    I am currently running Labview 7.1 on a Windows XP box.  I use Exceed to open a UNIX shell to do work in UNIX from my windows machine.  I can open the UNIX shell with the sys exec vi but how do I pass commands to the UNIX shell I opened?

    Purp1eOne wrote:
    I went to the sourceforge site to take a look and started the install process but after looking at the install instructions it says I need a run time engine of 8 or greater which I don't have:
    Kind of a novice here but I don't think this will work with LabView 7.1, will it?
    Also make sure you have
    the LabVIEW 8.2.1 Run-Time Engine installed.
    View Member Profile
    ipsmenu.register( "post-member-26", '', 'popmenubutton-new', 'popmenubutton-new-out' );
    Jul 17 2006, 08:53 PM
    Post
    #1
    Group: JKI Team
    Posts: 167
    Joined: 10-July 06
    Member No.: 7
    Note: The LabVIEW 8.0.1 and 8.2.1 run-time engines can co-exist
    together with the LabVIEW 8.5 (and newer) run-time engine. You still
    need to install the run-time engine's listed below to use VIPM, even if
    you have a newer version of LabVIEW installed.
    VIPM 1.1 and 2.0
    VIPM 1.1 and 2.0 require the LabVIEW 8.2.1 run-time engine installed on your machine.
    See also:Where do I get the LabVIEW 8.2.1 Run-Time Engine?
    VIPM 1.0
    VIPM 1.0 requires the LabVIEW 8.0.1 run-time engine installed on your machine.
    See also:
    Smercurio is right, and their is no OpenG package for the newer VIs so you will actually want to get them directly from CVS.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • SQL: Need help putting single quote around string

    I want to put single quotes around string in my output.
    I am running the following command as a test:
    select ' ' hello ' ' from dual;
    My expectation is to get 'hello' (Single quote around hello)
    However I am getting the following error:
    ERROR at line 1:
    ORA-00923: FROM keyword not found where expected
    When I do SHOW ALL at my SQL command prompt, the escape is set as follows:
    escape "\" (hex 5c)
    I even tried: select '\'hello\'' from dual;
    I get back: select ''hello'' from dual
    ERROR at line 1:
    ORA-00923: FROM keyword not found where expected

    Hi,
    user521525 wrote:
    I want to put single quotes around string in my output.
    I am running the following command as a test:
    select ' ' hello ' ' from dual;
    My expectation is to get 'hello' (Single quote around hello)You probably read that you can get a single-quote within a string literal by using two of them in a row.
    That's true, but they really have to be in a row (no spaces in between), and you still need the single-quotes at the beiginning and end of the literal.
    So what you want is
    SELECT  '''hello'''
    FROM    dual;Starting in Oracle 10, you can also use Q-notation, For example:
    SELECT  Q'['hello']'
    FROM    dual;

  • Place single quote around string

    Hi,
    I am wondering how I can Place single quote around string in the following. I have tried double and triple quote but it doesn't take variable name from rec.tablename.
    any idea
    rec.table_name ==> 'rec.table_name'
    rec.column_name ==> 'rec.column_name'
    v_sql:= 'DELETE USER_SDO_GEOM_METADATA WHERE TABLE_NAME= ' || rec.table_name ;
    execute immediate v_sql;
    -- Insert Table Record in Sdo_User_Geom_Metadata
    v_sql:= 'INSERT INTO USER_SDO_GEOM_METADATA(TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) ' ||
    'VALUES (' || rec.table_name || ',' || rec.column_name || ', MDSYS.SDO_DIM_ARRAY( ' ||
    'MDSYS.SDO_DIM_ELEMENT(''X'',-2147483648, 2147483647, .000005), ' ||
    'MDSYS.SDO_DIM_ELEMENT(''Y'',-2147483648, 2147483647, .000005)), 2958)' ;
    execute immediate v_sql;
    Nancy

    I have 2 suggestions, 2nd one being the better choice.
    SQL> set serveroutput on
    SQL>
    SQL> declare
      2    v_sql varchar2(4000);
      3    table_name varchar2(4000);
      4  begin
      5    table_name := 'MY_TABLE';
      6    v_sql:= 'DELETE USER_SDO_GEOM_METADATA WHERE TABLE_NAME= ''' || table_name || '''';
      7    dbms_output.put_line(v_sql);
      8  end;
      9  /
    DELETE USER_SDO_GEOM_METADATA WHERE TABLE_NAME= 'MY_TABLE'
    PL/SQL procedure successfully completed
    SQL> or using DBMS_ASSERT for a more elegant solution against SQL injection:
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
    Connected as fsitja
    SQL> set serveroutput on
    SQL>
    SQL> declare
      2    v_sql varchar2(4000);
      3    table_name varchar2(4000);
      4  begin
      5    table_name := dbms_assert.QUALIFIED_SQL_NAME('ALL_TABLES');
      6    v_sql:= 'DELETE USER_SDO_GEOM_METADATA WHERE TABLE_NAME= ' || dbms_assert.ENQUOTE_NAME(table_name);
      7    dbms_output.put_line(v_sql);
      8  end;
      9  /
    DELETE USER_SDO_GEOM_METADATA WHERE TABLE_NAME= "ALL_TABLES"
    PL/SQL procedure successfully completed
    SQL> [Docs referencing validation checks against SQL injection|http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10472/dynamic.htm#LNPLS648]
    Regards,
    Francisco

Maybe you are looking for