Search Results

Search found 1984 results on 80 pages for 'exec'.

Page 1/80 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • JDK 7u25: Solutions to Issues caused by changes to Runtime.exec

    - by Devika Gollapudi
    The following examples were prepared by Java engineering for the benefit of Java developers who may have faced issues with Runtime.exec on the Windows platform. Background In JDK 7u21, the decoding of command strings specified to Runtime.exec(String), Runtime.exec(String,String[]) and Runtime.exec(String,String[],File) methods, has been made more strict. See JDK 7u21 Release Notes for more information. This caused several issues for applications. The following section describes some of the problems faced by developers and their solutions. Note: In JDK 7u25, the system property jdk.lang.Process.allowAmbigousCommands can be used to relax the checking process and helps as a workaround for some applications that cannot be changed. The workaround is only effective for applications that are run without a SecurityManager. See JDK 7u25 Release Notes for more information. Note: To understand the details of the Windows API CreateProcess call, see: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx There are two forms of Runtime.exec calls: with the command as string: "Runtime.exec(String command[, ...])" with the command as string array: "Runtime.exec(String[] cmdarray [, ...] )" The issues described in this section relate to the first form of call. With the first call form, developers expect the command to be passed "as is" to Windows where the command needs be split into its executable name and arguments parts first. But, in accordance with Java API, the command argument is split into executable name and arguments by spaces. Problem 1: "The file path for the command includes spaces" In the call: Runtime.getRuntime().exec("c:\\Program Files\\do.exe") the argument is split by spaces to an array of strings as: c:\\Program, Files\\do.exe The first element of parsed array is interpreted as the executable name, verified by SecurityManager (if present) and surrounded by quotations to avoid ambiguity in executable path. This results in the wrong command: "c:\\Program" "Files\\do.exe" which will fail. Solution: Use the ProcessBuilder class, or the Runtime.exec(String[] cmdarray [, ...] ) call, or quote the executable path. Where it is not possible to change the application code and where a SecurityManager is not used, the Java property jdk.lang.Process.allowAmbigousCommands could be used by setting its value to "true" from the command line: -Djdk.lang.Process.allowAmbigousCommands=true This will relax the checking process to allow ambiguous input. Examples: new ProcessBuilder("c:\\Program Files\\do.exe").start() Runtime.getRuntime().exec(new String[]{"c:\\Program Files\\do.exe"}) Runtime.getRuntime().exec("\"c:\\Program Files\\do.exe\"") Problem 2: "Shell command/.bat/.cmd IO redirection" The following implicit cmd.exe calls: Runtime.getRuntime().exec("dir temp.txt") new ProcessBuilder("foo.bat", "", "temp.txt").start() Runtime.getRuntime().exec(new String[]{"foo.cmd", "", "temp.txt"}) lead to the wrong command: "XXXX" "" temp.txt Solution: To specify the command correctly, use the following options: Runtime.getRuntime().exec("cmd /C \"dir temp.txt\"") new ProcessBuilder("cmd", "/C", "foo.bat temp.txt").start() Runtime.getRuntime().exec(new String[]{"cmd", "/C", "foo.cmd temp.txt"}) or Process p = new ProcessBuilder("cmd", "/C" "XXX").redirectOutput(new File("temp.txt")).start(); Problem 3: "Group execution of shell command and/or .bat/.cmd files" Due to enforced verification procedure, arguments in the following calls create the wrong commands.: Runtime.getRuntime().exec("first.bat && second.bat") new ProcessBuilder("dir", "&&", "second.bat").start() Runtime.getRuntime().exec(new String[]{"dir", "|", "more"}) Solution: To specify the command correctly, use the following options: Runtime.exec("cmd /C \"first.bat && second.bat\"") new ProcessBuilder("cmd", "/C", "dir && second.bat").start() Runtime.exec(new String[]{"cmd", "/C", "dir | more"}) The same scenario also works for the "&", "||", "^" operators of the cmd.exe shell. Problem 4: ".bat/.cmd with special DOS chars in quoted params” Due to enforced verification, arguments in the following calls will cause exceptions to be thrown.: Runtime.getRuntime().exec("log.bat \"error new ProcessBuilder("log.bat", "error Runtime.getRuntime().exec(new String[]{"log.bat", "error Solution: To specify the command correctly, use the following options: Runtime.getRuntime().exec("cmd /C log.bat \"error new ProcessBuilder("cmd", "/C", "log.bat", "error Runtime.getRuntime().exec(new String[]{"cmd", "/C", "log.bat", "error Examples: Complicated redirection for shell construction: cmd /c dir /b C:\ "my lovely spaces.txt" becomes Runtime.getRuntime().exec(new String[]{"cmd", "/C", "dir \b \"my lovely spaces.txt\"" }); The Golden Rule: In most cases, cmd.exe has two arguments: "/C" and the command for interpretation.

    Read the article

  • php rsync with exec() not working

    - by mojeime
    Why this: rsync -avz -e ssh /home/userneme/folder [email protected]:/var/www/folder works from cronjob and this: exec("rsync -avz -e ssh /home/userneme/folder [email protected]:/var/www/folder"); doesn't work. I know exec is working because i have a few places in my appp that do convercion from pdf to jpg with ImageMagick (exec). SOLVED exec is working OK it was a permission issue on remote server. "Local" server is shared reseller account and remote server is my first VPS Ubuntu 10.10 LAMP box. If only I had a system administrator since i'm just a software developer forced to do this and i stink at it :) Thank You all!

    Read the article

  • Backup Exec 10 - Network connection to the remote agent has been lost

    - by jherlitz
    Okay, so I have 4 remote offices, all running off of a 3mb ethernet connection. Two sites are part of a WAN and 2 sites are using 3mb connections over a site to site tunnel. I am using Backup Exec 2010, I have the remote agent installed on all the remote servers. For the past few weeks now, on the two sites running over the site to site tunnel have been failing with the following error message now. "The network connection to the Backup Exec Remote Agent has been lost. Check for network errors" We used to be on a DSL connection site to site tunnel, now we changed to the 3mb ethernet connection using site to site tunnel. I have to find out, has it been failing ever since we changed, or just recently. Backup exec support is telling me it is a network issue. My communication or connection to the server is solid, we don't have any issues, or outages. So I am baffled on why this continues to fail. And why just those two sites.. Any advice?

    Read the article

  • CGI error from PHP when running exec() on IIS

    - by Patrick
    Windows Server 2003 x64 PHP 5.2 IIS 6.0 The program Ink2Png.exe is set with Everyone-Read and Execute permissions. As does its dependency (microsoft.ink.dll) PHP Safe Mode is off exec() is passed [the full exe path], space, [full path to another file] This other file also has full read permissions. The output directory has full write permissions. As soon as exec() is hit, the connection dies, the browser does not even receive a full set of http headers, and it reports a CGI error. Examining the output, it appears the program was not even run. Any ideas? How can I figure out what exactly is happening and get it running again? EDIT: Also, it is a .NET application, if that is significant in any way.

    Read the article

  • Exclude pings from apache error logs (ran from PHP exec)

    - by fooraide
    Now, for a number of reasons I need to ping several hosts on a regular basis for a dashboard display. I use this PHP function to do it: function PingHost($strIpAddr) { exec(escapeshellcmd('ping -q -W 1 -c 1 '.$strIpAddr), $dataresult, $returnvar); if (substr($dataresult[4],0,3) == "rtt") { //We got a ping result, lets parse it. $arr = explode("/",$dataresult[4]); return ereg_replace(" ms","",$arr[4]); } elseif (substr($dataresult[3],35,16) == "100% packet loss") { //Host is down! return "Down"; } elseif ($returnvar == "2") { return "No DNS"; } } The problem is that whenever there is an unknown host, I will get an error logged to my apache error log (/var/log/apache/error.log). How would I go about disabling logs for this particular function ? Disabling logs in the vhost is not an option since logs for that vhost are relevant, just not the pings. Thanks,

    Read the article

  • Java Runtime Exec for VBA script with arguments

    - by Holograham
    I am trying to use Runtime exec() to run a vba script with arguements. I am having trouble passing in the args. I think I need to use the String[] overloaded method for exec. Currently this works: String command = "cmd /c \"\\concat2.vbs\"" Process p = Runtime.getRuntime().exec(command); But I want to run that with arguments and if I do this String command = "cmd /c \"\\concat2.vbs\" " + arg1 + " " + arg2 where arg1 and arg2 are strings my program doesnt run (status = 1)

    Read the article

  • how to use a bash function defined in your .bashrc with find -exec

    - by sharrajesh
    my .bashrc has the following function function myfile { file $1 } export -f myfile it works fine when i call it directly rajesh@rajesh-desktop:~$ myfile out.ogv out.ogv: Ogg data, Skeleton v3.0 it does not work when i try to invoke it through exec rajesh@rajesh-desktop:~$ find ./ -name *.ogv -exec myfile {} \; find: `myfile': No such file or directory is there a way to call bash script functions with exec? Any help is greatly appreciated. Thanks, sharrajesh

    Read the article

  • How to run R through PHP with exec?

    - by dkar
    I am going to ask something, that I know that it has been asked already some times. But since, all of the past posts are quite old and none of them answer my problem..I try again. I am completely new in R language and relative new in php. What I want to do is to use the exec() function from php in order to execute a R script. Most of the people here will start talking about rapache, rserve and I don't know what else..but since I am not familiar with all these technologies, I prefer just using exec. The code I will show here is working just fine when I run it with Rscript from the terminal. # R script png("temp.png") plot(5,5) dev.off() But when I try to run it either with Rscript or with R CMD BATCH from PHP, like this: echo exec("Rscript my_rscript.R"); //OR //echo exec("R CMD BATCH my_rscript.R"); I get nothing back. I have checked if exec() function is available and if it works. Everything is ok with this. I read also, that I might have to change the permissions of the webserver...but I don't know how to do this in mamp. I hope I am clear with my problem and someone can help. Thanks Dimitris

    Read the article

  • MSBuild Working with ItemGroup and EXEC Command

    - by obautista
    I created the ItemGroup shown in the code snippet. I need to iterate through this ItemGroup and run the EXEC command - also shown in the code snippet. I cannot seem to get it to work. The code returns the error shown below (note - the Message is written 2 times, which is correct), but the EXEC Command is not running correctly. The value is not being set; therefore the EXEC is not executing at all. I need the EXEC to execute twice or by however sections I define in the ItemGroup. ERROR: Encrypting WebServer appSettings section Encrypting WebServer connectionStrings section C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pef "" "\gaw\UI" -prov "RSACustomProvider" Encrypting configuration section... The configuration section '' was not found. CODE SNIPPET: appSettings connectionStrings <Exec Command="$(AspNetRegIis) -pef &quot;%(SectionsToEncrypt.Section)&quot; &quot;$(DropLocation)\$(BuildNumber)\%(ConfigurationToBuild.FlavorToBuild)\$(AnythingPastFlavorToBuild)&quot; -prov &quot;$(WebSiteRSACustomProviderName)&quot;"/>

    Read the article

  • How to remove adornments like [exec] when using groovy's AntBuilder

    - by Miguel Pardal
    Hi! I'm using Groovy's AntBuilder to execute Ant tasks: def ant = new AntBuilder() ant.sequential { ant.exec(executable: "cmd", dir: "..", resultproperty: "exec-ret-code") { arg(value: "/c") arg(line: "dir") } } The output lines are prefixed by: [exec] Using Ant on the command line, this is turned off by "emacs mode" ant -emacs ... Is there a way to switch to emacs mode using AntBuilder?

    Read the article

  • Problem with running the Nutch command from PHP exec()

    - by Annibigi
    My Nutch directory lies in /home/myserv/nutch/nutch-1.0/ My php applictaion is in the diretcory /home/myserv/www/ Theres a a php file in my /home/myserv/www/ diretcory that runs a exec command to run a nutch command.PHP code is like : $output = exec("bin/nutch all"); When I run the command from the command line I need to be in the "/home/myserv/nutch/nutch-1.0/" directory When i'm trying to run it through the php exec() ,I just can seems to make it execute. I have tried giving the ful path like (below) but nothing works :( $output = exec("/home/myserv/nutch/nutch-1.0/bin/nutch all"); Desperately looking for help

    Read the article

  • python: strange behavior about exec statement

    - by ifocus
    exec statement: exec code [ in globals[, locals]] When I execute the following code in python, the result really confused me. Some of the variables were setup into the globals, some were setup into the locals. s = """ # test var define int_v1 = 1 list_v1 = [1, 2, 3] dict_v1 = {1: 'hello', 2:'world', 3:'!'} # test built-in function list_v2 = [float(x) for x in list_v1] len_list_v1 = len(list_v1) # test function define def func(): global g_var, list_v1, dict_v1 print 'access var in globals:' print g_var print 'access var in locals:' for x in list_v1: print dict_v1[x] """ g = {'__builtins__': __builtins__, 'g_var': 'global'} l = {} exec s in g, l print 'globals:', g print 'locals:', l exec 'func()' in g, l the result in python2.6.5: globals: {'__builtins__': <module '__builtin__' (built-in)>, 'dict_v1': {1: 'hello', 2: 'world', 3: '!'}, 'g_var': 'global', 'list_v1': [1, 2, 3]} locals: {'int_v1': 1, 'func': <function func at 0x00ACA270>, 'x': 3, 'len_list_v1': 3, 'list_v2': [1.0, 2.0, 3.0]} access var in globals: global access var in locals: hello world ! And if I want to setup all variables and functions into the locals, and keep the rights of accessing the globals. How to do ?

    Read the article

  • PHP exec() not executing batch files

    - by Andreas Bonini
    I tried googling for this issue and found many people with the same problem but no solution. $result = exec("C:\\Ruby191\\bin\\lessc.bat less\\$file", $output); Here result is an empty string and output an empty array. Same thing with: $result = exec("cmd /c C:\\Ruby191\\bin\\lessc.bat less\\$file", $output); I am sure the path is correct; I am sure exec() is enabled. I tried exec, shell_exec, system and none work. lessc is less CSS.

    Read the article

  • exec() function doesn't rule svn checkout

    - by bahamut100
    Hi, I'm writing some functions in php using exec() to interrogate a svn. The commands exec("svn list ".$myurl) works. Now, I try to get a path on a svn repository with the checkout command. When I put the command "svn checkout http://core.wordress.org/tags/2.9.2/ last-version" directly in the console, it works. But when I do this from a php script using exec(), like this : exec("svn checkout ".$myurl, $dir) it doesn't work. Have you an idea ??

    Read the article

  • Error during maven/ant build: "[java] Timestamp response not valid"

    - by fei
    My maven build started failing randomly, and it got the following error which I cannot make sense of, and googling it doesn't give me anything useful: [echo] Creating a full package... [java] Timestamp response not valid [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Failed to execute: Executing Ant script: /airtest.build.xml [package-admin-air]: Failed to execute. Java returned: 10 [exec] [DEBUG] Trace [exec] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute: Executing Ant script: /airtest.build.xml [package-admin-air]: Failed to execute. [exec] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719) [exec] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556) [exec] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535) [exec] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387) [exec] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348) [exec] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180) [exec] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328) [exec] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138) [exec] at org.apache.maven.cli.MavenCli.main(MavenCli.java:362) [exec] at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60) [exec] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [exec] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [exec] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [exec] at java.lang.reflect.Method.invoke(Method.java:597) [exec] at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) [exec] at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) [exec] at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) [exec] at org.codehaus.classworlds.Launcher.main(Launcher.java:375) [exec] Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to execute: Executing Ant script: /airtest.build.xml [package-admin-air]: Failed to execute. [exec] at org.apache.maven.script.ant.AntMojoWrapper.execute(AntMojoWrapper.java:56) [exec] at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490) [exec] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694) [exec] ... 17 more [exec] Caused by: org.codehaus.plexus.component.factory.ant.AntComponentExecutionException: Executing Ant script: /airtest.build.xml [package-admin-air]: Failed to execute. [exec] at org.codehaus.plexus.component.factory.ant.AntScriptInvoker.invoke(AntScriptInvoker.java:227) [exec] at org.apache.maven.script.ant.AntMojoWrapper.execute(AntMojoWrapper.java:52) [exec] ... 19 more [exec] Caused by: C:\Users\dev\plexus-ant-component4263631821803364095.build.xml:445: Java returned: 10 [exec] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:87) [exec] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [exec] at org.apache.tools.ant.Task.perform(Task.java:364) [exec] at org.apache.tools.ant.Target.execute(Target.java:341) [exec] at org.apache.tools.ant.Target.performTasks(Target.java:369) [exec] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [exec] at org.apache.tools.ant.Project.executeTarget(Project.java:1185) [exec] at org.codehaus.plexus.component.factory.ant.AntScriptInvoker.invoke(AntScriptInvoker.java:222) This is a random error that pops up in various point during the build process, and sometimes the build will succeed and then the next one will fail again. This is really weird, does anyone seen this before? I'm using maven 2.2.1 BTW, the error return code 10 in windows mean "Environment is invalid.

    Read the article

  • Process spawned by exec-maven-plugin blocks the maven process

    - by Arnab Biswas
    I am trying to execute the following scenario using maven : pre-integration-phase : Start a java based application using a main class (using exec-maven-plugin) integration-phase : Run the integration test cases (using maven-failsafe-plugin) post-integration-phase: Stop the application gracefully (using exec-maven-plugin) Here is pom.xml snip: <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <id>launch-myApp</id> <phase>pre-integration-test</phase> <goals> <goal>exec</goal> </goals> </execution> </executions> <configuration> <executable>java</executable> <arguments> <argument>-DMY_APP_HOME=/usr/home/target/local</argument> <argument>-Djava.library.path=/usr/home/other/lib</argument> <argument>-classpath</argument> <classpath/> <argument>com.foo.MyApp</argument> </arguments> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.12</version> <executions> <execution> <goals> <goal>integration-test</goal> <goal>verify</goal> </goals> </execution> </executions> <configuration> <forkMode>always</forkMode> </configuration> </plugin> </plugins> If I execute mvn post-integration-test, my application is getting started as a child process of the maven process, but the application process is blocking the maven process from executing the integration tests which comes in the next phase. Later I found that there is a bug (or missing functionality?) in maven exec plugin, because of which the application process blocks the maven process. To address this issue, I have encapsulated the invocation of MyApp.java in a shell script and then appended “/dev/null 2&1 &” to spawn a separate background process. Here is the snip (this is just a snip and not the actual one) from runTest.sh: java - DMY_APP_HOME =$2 com.foo.MyApp > /dev/null 2>&1 & Although this solves my issue, is there any other way to do it? Am I missing any argument for exec-maven-plugin?

    Read the article

  • Exec Maven Plugin to Command Line

    - by mistercaste
    I have an application developed in NetBeans/Maven that can be started via command line with: mvn exec:exec "-Dexec.executable=C:\\Java\\jdk1.6.0_33\\bin\\java.exe" "-Dexec.args=-Dlog4j.properties=... -classpath %classpath com.xxx.MyLauncher" -Dexec.classpathScope=runtime -Dexec.workingdir= Now I need to run the application through the standard java command line method, like: java -Dlog4j.properties=... -jar myapp-1.2-SNAPSHOT.jar Unfortunately this does not work in the same manner, as I get the following exception: opencard.core.util.OpenCardPropertyLoadingException: property file not found Questions: What is the difference between launching applications with the Exec-Maven-plugin and the standard java execution on command line? Is there an easy way to convert a Maven execution script to a standard command line? How to run the application succesfully?

    Read the article

  • How to stop nant exec task putting ( ) around command line

    - by Sam
    I have looked through the nant documentation and sourceforge faq and can't find the answer to this question. The exec task in nant puts ( ) around the command line parameters it generates, so for example this task below would generate: mallow ( -1 ) <exec program="${build.tools.wix}\mallow.exe" workingdir="${build.out.xxx}"> <arg value="-1" /> </exec> The other open source tool I'm using - mallow - cannot handle this. Does anyone know of a way to stop nant putting the ( ) around the arguments? Thanks.

    Read the article

  • javascript string exec strange behavior

    - by Michael
    have funciton in my object which is called regularly. parse : function(html) { var regexp = /...some pattern.../ var match = regexp.exec(html); while (match != null) { ... match = regexp.exec(html); } ... var r = /...pattern.../g; var m = r.exec(html); } with unchanged html the m returns null each other call. let's say parse(html);// ok parse(html);// m is null!!! parse(html);// ok parse(html);// m is null!!! // ...and so on... is there any index or somrthing that has to be reset on html ... I'm really confused. Why match always returns proper result?

    Read the article

  • Why are closures broken within exec?

    - by Devin Jeanpierre
    In Python 2.6, >>> exec "print (lambda: a)()" in dict(a=2), {} 2 >>> exec "print (lambda: a)()" in globals(), {'a': 2} Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<string>", line 1, in <module> File "<string>", line 1, in <lambda> NameError: global name 'a' is not defined >>> exec "print (lambda: a).__closure__" in globals(), {'a': 2} None I expected it to print 2 twice, and then print a tuple with a single cell. It is the same situation in 3.1. What's going on?

    Read the article

  • how to redirect stdin to java Runtime.exec ?

    - by jprogram2010
    I want to execute some sql scripts using Java's Runtime.exec method. I intend to invoke mysql.exe / mysql.sh and redirect the script file to this process. From the command prompt I can run the command <mysqInstallDir\/bin\mysql.exe -u <userName> -p <password> < scripts\create_tables.sql I can invoke mysql.exe using Runtime.exec but how do I redirect data from sql file to mysql.exe ?

    Read the article

  • crude Runtime.exec to call java -cp not working in linux

    - by pstanton
    I'm using a java process to spawn many other java processes using Runtime.exec(cmd) where cmd is like the following: java -cp "MyJar.jar" pkg.MyClass some-more-arguments running the same command from the command line works fine in windows and linux, however when my spawning java process calls the command via Runtime.exec it works in windows but not in linux. in linux i get Exception in thread "main" java.lang.NoClassDefFoundError: pkg/MyClass any ideas?

    Read the article

  • Java - Runtime.getRuntime().exec() what's going on?

    - by kunkanwan
    Hi, I have problem with Runtime.exec() in Java My code: String lol = "/home/pc/example.txt"; String[] b = {"touch", lol}; try { Runtime.getRuntime().exec(b); } catch(Exception ex) { doSomething(ex); } It's working good but when I trying changle variable "lol" files doesn't create in hard disk for instance: String lol = x.getPath(); where getPath() returns String What should I do ? Thanks for your reply :)

    Read the article

  • use exec for dsadd

    - by Daryl Gill
    I'm Programming on a Windows Server 2008 and I wish to have a WebUI to interact with the domains active directory. One of my main problems is this that i'm using dsadd from a HTML form but this is no succeeding. I know my command is correct, I have tested it out on the Servers Command line My Code is As Below: if (isset($_POST['Submit'])) { $DesiredUsername = $_POST['DesiredUsername']; $DesiredPassword = $_POST['DesiredPassword']; $DU = "{$DesiredUsername}"; // Desired Username $OU = "PHPCreatedUsers"; // Domain OU $DC1 = "slayerserv"; // Domain Part one $DC2 = "local"; // Domain Part Two $PWD = "{$DesiredPassword}"; // Password $ExecScript = 'dsadd user cn=$DesiredUsername,cn=PHPCreatedUsers,dc=slayerserv,dc=local -disabled no -pwd $DesiredPassword -mustchpwd yes'; exec($ExecScript, $output); mysql_query("INSERT INTO addedusers (`ID`, `DU`, `OU`, `DC1`, `DC2, `PWD`) VALUES ('', '$DU', '$OU', '$DC1', '$DC2', '$PWD')"); echo "<br><br>"; print_r($output); # echo "User: $DesiredUsername Has been Created"; } When I print_r($output); it Returns a blank array: Array ( ) Could anyone provide me with a solution or point me in the right direction? ++++ Below is a working example of my usage of exec $Script = 'ping 127.0.0.1 -n 1'; exec($Script, $Output); print_r($Output); print_r($Output); Gives: Array ( [0] = [1] = Pinging 127.0.0.1 with 32 bytes of data: [2] = Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 [3] = [4] = Ping statistics for 127.0.0.1: [5] = Packets: Sent = 1, Received = 1, Lost = 0 (0% loss), [6] = Approximate round trip times in milli-seconds: [7] = Minimum = 0ms, Maximum = 0ms, Average = 0ms )

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >