Can I Pass String with Spaces in it To exec()

Hello All,
I am passing a Command in Runtime.exec() method, which is a String and contains a folder name(Folder---Name) which is having Spaces in it. For eg. c:/Folder/Folder(Spaces in between)Name/Data.java
My Problem is when i pass it to exec() it automatically gets converted to a Folder name with only one space
E.g c:/Folder/Folder(One Space in between)Name/Data.java,
Because of which my command is not able to find the Folder specifed.
I want the Original Path(c:/Folder/Folder(Spaces in between)Name/Data.java) to be passed and executed through
exec() so that the command runs successfully..........
Any help will be highly appreciable..
Thanks
Er.Atul

When I make a simple array of String a, Try to run simple command like "change Directory"....
*try {*+
String[] a = {"cd atul", "cd poc"};+
Runtime runtime = Runtime.getRuntime();+
Process procedure = runtime.exec(a);+
+*} catch (IOException ex) {*+
Logger.getLogger(Testing.class.getName()).log(Level.SEVERE, null, ex);+
It Gives me this type of Exception............
Feb 20, 2009 5:13:36 PM Testing <init>
SEVERE: null
java.io.IOException: Cannot run program "cd atul": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:466)
at Testing.<init>(Testing.java:26)
at Testing.main(Testing.java:36)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
*... 4 more*

Similar Messages

  • Passing arguments with spaces through to asc.jar

    According to the docs, we can pass arguments through to llc using -fllvm-llc-opt.  Additionally, with llc we can pass arguments through to asc.jar using -ascopt.  Let's say I want to define an AS3 variable in my flascc swf/swc.  asc.jar says that I can do this using "-config <ns::name=value>".
    So it seems like I should be able to do this:
    gcc ... -fllvm-llc-opt=-ascopt=-config CONFIG::RELEASE=true
    But this doesn't work, as the "-config" parameter takes its next argument via a space and not an equals, which throws the whole thing off.  gcc thinks its another argument.  Trying it with spaces like this:
    gcc ... "-fllvm-llc-opt=-ascopt=-config CONFIG::RELEASE=true"
    also doesn't work.  The toolchain outputs:
    Error:
    LLVM ERROR: Failed to run /usr/bin/java with args:
    -Xmx1500M -jar /Users/asimmons/FlasCC_1.0/sdk/usr/bin/../../usr/lib/asc2.jar -merge -md -abcfuture -AS3
    -import /Users/asimmons/FlasCC_1.0/sdk/usr/bin/../../usr/lib/builtin.abc -import /Users/asimmons/FlasCC_1.0/sdk/usr/bin/../../usr/lib/playerglobal.abc -import /Users/asimmons/FlasCC_1.0/sdk/usr/bin/../../usr/lib/BinaryData.abc -import /Users/asimmons/FlasCC_1.0/sdk/usr/bin/../../usr/lib/Exit.abc -import /Users/asimmons/FlasCC_1.0/sdk/usr/bin/../../usr/lib/LongJmp.abc -import /Users/asimmons/FlasCC_1.0/sdk/usr/bin/../../usr/lib/ISpecialFile.abc -import /Users/asimmons/FlasCC_1.0/sdk/usr/bin/../../usr/lib/IBackingStore.abc -import /Users/asimmons/FlasCC_1.0/sdk/usr/bin/../../usr/lib/InMemoryBackingStore.abc -import /Users/asimmons/FlasCC_1.0/sdk/usr/bin/../../usr/lib/IVFS.abc -import /Users/asimmons/FlasCC_1.0/sdk/usr/bin/../../usr/lib/CModule.abc
    -config CONFIG::RELEASE=false -d /var/folders/cn/hjz9nbt53bdfpn1rzn6wdb900000gr/T//ccQPoczK.lto.2.as /var/folders/cn/hjz9nbt53bdfpn1rzn6wdb900000gr/T//ccZDGxMF.lto.1.as -outdir . -out output
    As you can see, the "-config" command made it to asc.jar.  What I think is happening is that its being passed to asc.jar as one argument (not two).  For example, I can copy-paste this command into bash and it will work-- just not when done from gcc.
    So: how do I pass arguments with spaces through to asc.jar?

    I believe you should be able to do this by splitting it across two fllvm-llc-opt flags:
    gcc ... -fllvm-llc-opt=-ascopt=-config -fllvm-llc-opt=-ascopt=CONFIG::release=true
    The Makefile in the 12_Stage3D sample that ships with the FlasCC SDK demonstrates this.

  • Use REGEXP_INSTR to find a text string with space(s) in it

    I am trying to use REGEXP_INSTR to find a text string with space(s) in it.
    (This is in a Function.)
    Let's say ParmIn_Look_For has a value of 'black dog'. I want to see if
    ParmIn_Search_This_String has 'black dog' anywhere in it. But it gives an error
    Syntax error on command line.
    If ParmIn_Look_For is just 'black' or 'dog' it works fine.
    Is there some way to put single quotes/double quotes around ParmIn_Look_For so this will
    look for 'black dog' ??
    Also: If I want to use the option of ignoring white space, is the last parm
    'ix' 'i,x' or what ?
    SELECT
    REGEXP_INSTR(ParmIn_Search_This_String,
    '('||ParmIn_Look_For||')+', 1, 1, 0, 'i')
    INTO Position_Found_In_String
    FROM DUAL;
    Thanks, Wayne

    Maybe something like this ?
    test@ORA10G>
    test@ORA10G> with t as (
      2    select 1 as num, 'this sentence has a black dog in it' as str from dual union all
      3    select 2, 'this sentence does not' from dual union all
      4    select 3, 'yet another dog that is black' from dual union all
      5    select 4, 'yet another black dog' from dual union all
      6    select 5, 'black dogs everywhere...' from dual union all
      7    select 6, 'black dog running after me...' from dual union all
      8    select 7, 'i saw a black dog' from dual)
      9  --
    10  select num, str
    11  from t
    12  where regexp_like(str,'black dog');
           NUM STR
             1 this sentence has a black dog in it
             4 yet another black dog
             5 black dogs everywhere...
             6 black dog running after me...
             7 i saw a black dog
    5 rows selected.
    test@ORA10G>
    test@ORA10G>pratz
    Also, 'x' ignores whitespace characters. Link to doc:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions007.htm#i1048942
    Message was edited by:
    pratz

  • Padding String with spaces -tried known methods but code not working!

    I am trying to figure out an easy way to pad a string with spaces at the end. The way that definitely works is a for loop where string = string + " "; until string is the length that I need. However, for several dozen strings this is a lot of unnecessary overhead. I've done some research and tried a few different things - yet none of them seem to actually pad the string.
    import org.apache.commons.lang.StringUtils;
    public class Test
         public static void main(String[] args)
              String one = "1234";
                    //print string at current lenght
              System.out.println(one+"*");
                    //try padding using String.format (in padRight method below)
              one = padRight(one,(8-one.length()));
              System.out.println(one+"*");
                    one="1234";
                    //try padding using StringUtils
              String tmp = StringUtils.rightPad(one, (8-one.length()));
              System.out.println(tmp+"*");
         private static String padRight(String s, int n)
              return String.format("%1$-" + n + "s", s);
    }I've researched and these are the two most common methods people are suggesting. I am using java 1.5 so the String.format should work.. however, when I run it (I use JBuilder) the output is always "1234*".... after I try to pad it the output should be "1234 *" (with 4 spaces between the 4 and *) . Any suggestions is greatly appreciated! Thanks in advance.

    Wow, I completely botched that... uncle_alice, thank you for clearing that up for me.
    pbrockway2 - thank you, I actually did peruse the Formatter documentation - I would never post without researching something first... but I must have read it with one eye shut because walked away with the impression that I needed to submit the difference. I obviously misunderstood the documentation.
    Thanks!

  • How to concatenate a string with spaces

    Dear experts,
    I would like to concatenate a string with three spaces, for example,
    CONCATENATE 'X' SPACE SPACE SPACE 'Y' INTO LV_RESULT.
    However, the result I got from executing the above statement is not 'X   Y' as I want, but rather 'XY'.
    I did try
    CONCATENATE 'X' '***' 'Y' INTO LV_RESULT.
    REPLACE '***' with '   ' INTO LV_RESULT.
    still doesn't work.
    How can I write ABAP code to archive such a result?
    Any idea would be appreciated.
    Vitthavat A.

    dear  Oliver Hütköper and koolspy,
    I tried your solutions, and it works.
    so i awarded points to you.
    anyway, while trying the 'respecting blanks', i got an error:
    "".", "IN BYTE MODE", "SEPARATED BY ..." or "IN CHARACTER MODE" expected"
    not sure what it means. but it's ok. the problem has been solved.
    thanks again.

  • RWCLIENT issue when passing parameters with spaces

    AS 10.2.0.2 on Sun Solaris 10. We have reports that are scheduled and sum of the parameters have spaces in the value. For example parm1=I am with spaces. We would then generate a command line that shows the parameter like rwclient.sh server=rep_serv report=report1 parm1=I am with spaces. This errors with numerous messages. I tried surrounding the value in single quotes like this rwclient.sh server=rep_serv report=report1 parm1='I am with spaces'. When running the quoted command the report server shows the parameter as parm1='I' am with spaces. We have the parameter page of the report as the first page which allows us to see what was actually used as parameters. Of course the data in the database has no value that matches with the single quotes so no data. I need to be able to pass a value with spaces and it actually show as a parameter with spaces. We do not have this issue when we can run with forms built-ins as you actually build a parameter list to pass. Thanks in advance.
    Edited by: gdaustin1 on Jan 26, 2012 8:03 AM

    It's a bit of both I guess. On a command line a space is used to separate switches and variables. Like this demo.bat:
    @echo off
    echo %1Results in:
    C:\Temp>demo.bat Hello World
    Hello
    C:\Temp>demo.bat "Hello World"
    "Hello World"If you want to remove the double quotes, you have to change your source code to:
    @echo off
    echo %~1Now you get:
    C:\Temp>demo.bat "Hello World"
    Hello World

  • Passing parameters with spaces in Oracle reports

    I hav a system that passes a query string to a servlet and generates an Oracle Report. All of the varibles worked Ok as long as they don't have spaces in them. Whenever a parameter with spaces is encountered,it generates an error. i tried to enclose it in single or double quotes but it didn't work. I also tried to insert the Url Encode for spaces which is %20 but it also generated an error. pls help me on this one...

    I suppose you're working with GET instead of POST. Try to use the POST method; this gives you the possibility to work with a URL without parameters behind the question mark. This might be the solution to your problem.

  • Passing parameter with space?

    How does java pass parameter value with spaces? e.g. url?param1=value with space .
    Is there any built in method like PHP's addslashes?
    Thanks.

    URLEncoder.encode("value with
    space","UTF-8")Also the core JSTL tag c:url will encode parameters with spaces, and of course there's the crude way of just using the + sign.

  • Breadcrumbs containing string with spaces - generating the anchor

    so I have a website that contains a 'breadcrumbs' line that allows users to click on it, and take them back to the parent page
    eg. "jewellery"
    I simply suffix this string with ".cfm" to generate the anchor / filename
    what's the best way to deal with strings containing spaces?
    eg. "birthday cards"
    As good practice I want to use a more compatiable filename that doesn't include spaces
    eg. "birthday_cards.cfm"
    is the REPLACE command ok to use ? or is preferrable to add an additonal field to the table, called "filename" and store the exact filename in there ?

    option 1
    use quotes like href="http:\\....."
    option 2
    convert spaces to %2B

  • [SOLVED]Audacious can't open files with spaces on name

    I open audacious
    Type Ctrl+o and select a directory with spaces on it names,
    Audacious opens nothing
    Any ideas?
    I have deep trees of music with spaces, I was working on a script to rename one by one, but I'm too lazy
    Cheers
    Last edited by geckos (2014-01-29 21:32:33)

    Here is my solution, I did this for every error that apears like that...
    [geckos@localhost ~]$ audacious
    (bootstrap.c:60) [mowgli_init]: mowgli_init() is a deprecated function, provided only for backwards compatibility with Mowgli-1. You should remove it if you no longer support using Mowgli-1.
    *** ERROR: /usr/lib/audacious/Input/cdaudio-ng.so could not be loaded: libcdio_cdda.so.1: cannot open shared object file: No such file or directory
    ^C[geckos@localhost ~]$
    [geckos@localhost ~]$ pkgfile -r '.*/libcdio_cdda.so.1'
    extra/libcdio-paranoia
    [geckos@localhost ~]$ sudo pacman -Syu libcdio-paranoia
    :: Synchronizing package databases...
    (3/3) installing libcdio-paranoia [###########################################] 100%
    [geckos@localhost ~]$
    [geckos@localhost ~]$

  • Padding a string with spaces

    How do you pad a string w spaces using "Format into a string" w/o typing /s/s/s/s/s for say 5 spaces ?
    Solved!
    Go to Solution.
    Attachments:
    printed output.PNG ‏6 KB
    wire diagram.PNG ‏11 KB

    Hi Clint,
    this way:
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Can Cisco ASA work with spaces in LDAP DN string to authenticate and assign group policies?

    I am having the hardest time getting a definitive answer to this;  basically, I have a Cisco ASA firewall that is using AD via LDAP to authenticate  users and assign them a group policy based on certain AD group memberships.
    The problem I think I have is that due to how our AD forest is structured, I have spaces in the DN string, as shown below...  I have tried enclosing the entire string in quotes, etc.  - nothing seems to work.  Basically, the string is not matched, and the users are assigned a non-matching default policy.  Cisco TAC thinks it is due to the spaces (highlighted) but I am not sure sure.
    Can some one please advise?
    CN=VPN_SSL_SPLIT,OU=Grps - ACS,OU=Res - Groups,OU=BU - Vesna.Resources,DC=DOM1,DC=US,DC=LOCAL

    We can troubleshoot this issue. Please provide me the following outputs:
    show run aaa-server
    show run ldap
    Turn on "debug ldap 255" and reproduce the issue. Paste the output here.
    Regards,
    Jatin Katyal
    *Do rate helpful posts*

  • Passing parameters with spaces to SCCM Run PowerShell Script task

    I am working on an OS deployment task sequence in SCCM 2012 R2 with several Run PowerShell Script tasks.  Most of them run fine, but I am having trouble with the one I need to pass parameters to.
    The parameters I need to pass are:
    -ComputerOU "ou=All Workstations,dc=contoso,dc=com" -GroupDN "cn=Group1,ou=All Groups,dc=contoso,dc=com"
    I have that line (with actual DNs) entered in Parameters of the task.
    But when the script runs on the target machine, the values of the parameters in the script are truncated at the spaces.  $ComputerOU is set to "ou=All" and $GroupDN is set to "cn=Group1,ou=all"
    What syntax should I be using the Parameters field of the Task in order to properly pass PowerShell parameter string values that include spaces?
    Tim Curwick
    MadWithPowerShell.com

    Thank you, TC, but I am not calling the parameters from within PowerShell.
    The parameters are in the settings of a task sequence task to be used by the task to launch a script.  The syntax I am using would be correct for use within PowerShell or from a command line or batch script, but SCCM appears to be doing some parsing
    before or while it is passing them to the script, possibly dropping the quotes which causes mishandling of the spaces in the string values.
    Historically, it is always challenging to give one application parameters to pass to another application, and the required syntax can get quite tricky when the two application handle quotes or spaces differently, or when the parent application wants to parse
    something intended to be passed on as is to the child application.
    I'm sure someone has already figured out what the syntax needs to be for doing this with an SCCM 'Run PowerShell Script" task, it's just one of those issues that is hard to Google effectively.
    Any other ideas?
    Tim Curwick
    MadWithPowerShell.com

  • READURL Call on Macintosh, won't pass variables with spaces???

    Here is my code and the problem. I am trying to passing a
    tablename and a classname with READURL and the PHP script takes the
    info and returns to me my classid. This works wonderfully on the
    PC, but on the MAC, when I click on a classname with a space I get
    back a empty string as my return value.....here is my code from AW
    and PHP......If you can help I would readlly appreciate it.

    http doesn't like spaces in URLs.
    This clicking on a classname -- is that happening on a web
    page, or in AW?
    Either way, you should urlencode the link. Replace any spaces
    in the URL
    with + signs, either manually on a web page, or by using the
    replace
    function in AW [replace("", "+", string)]. Then, in your PHP
    script, you can
    change the $_classname assignment to include urldecode:
    $_classname = urldecode($_GET["classname"]);
    This should return it to the multi-word format.
    Paul Swanson
    Portland, Oregon, USA
    "bradsteele" <[email protected]> wrote in
    message
    news:[email protected]...
    > Here is my code and the problem. I am trying to passing
    a tablename and a
    > classname with READURL and the PHP script takes the info
    and returns to me
    my
    > classid. This works wonderfully on the PC, but on the
    MAC, when I click
    on a
    > classname with a space I get back a empty string as my
    return
    value.....here is
    > my code from AW and PHP......If you can help I would
    readlly appreciate
    it.
    >
    >
    >
    > getClassID.php code ....
    >
    > <?PHP
    >
    > // MAKE THE SCRIPT NON_CACHEABLE
    > header("Expires: Mon, 26 Jul 1990 05:00:00 GMT");
    > header("Last-Modified: " . gmdate("D, d M Y H:i:s",
    time() + 300) . "
    GMT");
    > header("Cache-Control: no-cache, must-revalidate");
    > header("Pragma: no-cache");
    >
    > // SET VARIABLES
    > $_table = $_GET["table"] . "_classes";
    > $_classname = $_GET["classname"];
    >
    > // LOGIN TO THE DATABASE
    > mysql_connect("localhost", "user", "user") or
    die("Cannot connect to
    DB!");
    > mysql_select_db("trek") or die("Cannot select DB!");
    >
    > // GET CLASS ID
    > $sql = "SELECT classid FROM `$_table` where classname =
    '$_classname'";
    > $r = mysql_query($sql);
    >
    > // IF MORE THAN 1 ROW, THEN PRINT FALSE (ERROR)
    >
    > while ($row = mysql_fetch_assoc($r)) {
    > $query = $row['classid']; }
    > print $query;
    > ?>
    >
    >
    > AUTHORWARE 7.02 CODE BELOW:
    >
    > -- Get the Class ID
    > if NetConnected then
    > www_action := "?action=getData"
    > www_query :="&table=" ^ tablePrefix ^
    "&classname=" ^
    LowerCase(ClassName)
    > www_URLString := NetLocation ^ "getClassID.php" ^
    www_action ^
    www_query
    > www_ClassID := ReadURL(www_URLString, 10)
    > end if
    >

  • Process.start("winword", filename) can not open file with space in the path and name

    Hi,
    I am trying to write a class which can open file with selected application. for simplicity, now I just hard code the varaibles.
    the problem: if the path or file name has space in it, even it exist, winword still can not open it.
    could someone kindly show me what I did wrong and how to do it properly.
    Thanks in advance.
    Belinda
    public static class FileOpen
    public static void info()
    string path = @"c:\a temp folder\aaa 1.txt";
    if (File.Exists(path))
        // the file I am using in the sample does exist
         MsgBox.info("yes");
    else
         MsgBox.info("no");
    // working
    //Process.Start("winword", "c:\\aaa.txt");
    // not working
    //Process.Start("winword", "c:\aaa.txt");
    // not working
    Process.Start("winword", "c:\\a temp folder\\aaa 1.txt");
    // not working
    Process.Start("winword", path);

    string AppPath;
    AppPath = ReadRegistry(Registry.CurrentUser, "Software\\FabricStudio", "TARGETDIR", value).ToString() + @"help";
    string FileName = "'"+ AppPath + "\\ImageSamples.doc" + "'";
    try
    System.Diagnostics.Process.Start("Winword.exe", FileName);
    can any body please help for this.
    where i am making mistake?

Maybe you are looking for

  • Does anyone know how to show the year in the menubar?

    I've never been able to do this. YouControl.app did do it but sadly the developer is no longer supporting it.

  • BI Integration with ADF

    I am able to run the ADF Application(BI Reports integration) successful on integrated server by doing the below things, 1) installed all required libraries 2) created a BI connection under Application Resources connections 3) created a sample applica

  • 24' cinema display stuck in 640 X 480 - unless used in Apple Store!

    I really need some help with my new MBP and 24" LED cinema display that is driving me crazy. The first part of the problem is that when I bring my MBP out of sleep and attach the monitor, or if I simply disconnect the monitor and reconnect it without

  • Screen Flickering Everytime After Updating Synaptics Touchpad Driver And Touchpad Not Working

    I have a HP ENVY 4 1023tu Notebook with Windows 8 Pro. I always keep my pc updated. But whenever i try updated the synaptics touchpad driver through availabe updates by hp support assistant, the screen starts to flicker(Start screen and settings bar

  • InDesign CS5.5 crashing on startup

    Every time I try and open InDesign, it crashes at the "Initiating plugins" stage. I've tried deleting/moving certain plugins, getting the Adobe plugins update, everything I've found online. Nothing seems to work. Help!