EXEC Function in LINUX

Hi,
After processing a flat file in DS, I want to move it to an archive directory.
The command I'm using in a script is
$G_Return_Msg = exec('bash','mv /u02/home/bobje/eric.test /u02/home/bobje/ejtestdir',8);
print('==  [$G_Return_Msg] ==');
but it returns the following error message -
== 126: /bin/mv: /bin/mv: cannot execute binary file ==
Can anybody tell me what I'm doing wrong ?
Thanks,
Eric Jones.

you are passing mv commad as argument to bash, this will executed as bash mv a b, which is wrong if you want to open a shell and execute a command in it then pass the command with -c option, check man page for sh, ksh etc
try using the following syntax
$G_Return_Msg = exec('sh',' -c mv /u02/home/bobje/eric.test /u02/home/bobje/ejtestdir',8);
or put this command in .sh file and inovke that script form exec() as below
put the following command in script /u02/home/bobje/move.sh
mv /u02/home/bobje/eric.test /u02/home/bobje/ejtestdir
$G_Return_Msg = exec('/u02/home/bobje/move.sh', '' ,8);

Similar Messages

  • Exec function issue on linux

    I have a java daemon process A. Process A uses the Runtime.getRuntime.exec() function to run other java process(es) B at fixed intervals. Both A and B do not display any windows, frames, dialogs , messages etc...
    Process A is started via commandline in ...../FolderA:
    java - cp .:classesA.jar processA
    In Process A, I use the exec function to launch Process B, in ..../FolderB as follows:
    String command = java - cp .:classesB.jar processB
    String workingDir = ...../FolderB
    String envArray[] = null;
    prcs = Runtime.getRuntime().exec(command,envArray,workingDir);
    On Windows:
    1) I can start Process A via commandline on windows, and it runs Process B correctly
    2) I telnet to the windows system from linux, and start Process A. It still runs Process B correctly.
    On Linux:
    1) I start Process A via commandline from RedHat desktop terminal, and it runs Process B correctly, but I get the following message:
    Warning: Cannot convert string "<Key>Escape,_Key_Cancel" to type VirtualBinding
    Warning: Cannot convert string "<Key>Home,_Key_Begin" to type VirtualBinding..... + 4 more similar warnings
    Even with these warnings, process B runs fine and returns with exit code = 0,
    2) However, If I telnet to Linux from windows, and start Process B, then Process B fails and returns with exit code = 1. Also, no warning or error information is available from the runtime.exec function.
    It seems like an 'environment' issue related to X11 or some shell setting needs to be put into envArray[]. I am not a Unix person and have no idea about fixing something like this. Any inputs would be appreciated.

    In the GUI environment (whether you really use it or the JVM just thinks it is needed) the DISPLAY variable has to point to the X server. If you leave it out from the enviroment when exec'ing the second JVM from the first one, then it will become a problem.

  • Open a *.exe applicatio​n in LABVIEW with system exec function.

    Greetings,
    I would like to be able to lauch a *.exe application and open a specific file within my labview vi. The trick is to avoid using active X control at all cost. I would like to use the system exec function but I couldn't quite get it to work.
    Let's assume that I would like to lauch wordpad.exe from my local drive. What are the params I need to pass? Thanks.

    You have to type in the command line of the System exec vi the name of the executable and eventually its path.
    Look at the attached vi that launches Wordpad as you asked.
    Attachments:
    wordpad_exec.vi ‏72 KB

  • Runtime.exec() on RedHat Linux

    Guys
    Like many before me, it seems, I've having a nightmare with Runtime.exec() across platforms when executing local files.
    I've gone for the basic but robust strategy of writing the required function to a local file and then executing the file. This has worked fine on Windows NT/2000 and on Solaris. But RedHat Linux doesn't want to know.
    I know my permissions are good to execute. I can create the file then run it at the command line, but then whenever I go to run from within Java I get an exit value of 255.
    An old chestnut, I know. But can anyone offer an help?
    Cheers
    Dom

    Here's a small class & main method that illustrates the problem.
    The output I get is:
    File path: /tmp/Temp26345.sh
    chmod +x exit value: 0
    Executing file: 255
    I can then go into /tmp and run ./Temp26345.sh at the command line and get the "ls" command to run.
    import java.io.*;
    public class FileExecutor
         public static void main( String[] args )
              if( args.length == 0 )
                   System.out.println("Arguments must be given: [filename] [writeable]");
                   return;
              try
                   FileExecutor fe = new FileExecutor();
                   File executable = fe.createFile( args[0] , args[1] );
                   fe.executeFile( executable );
              catch( Throwable t )
                   t.printStackTrace();
         public File createFile( String fileName , String contents )
              throws IOException
              //Create the file.
              File tempFile = File.createTempFile( fileName , ".sh" );
              //Write to the file.
              FileOutputStream fos = new FileOutputStream( tempFile );
              OutputStreamWriter osw = new OutputStreamWriter( fos, "UTF-8" );
              int length = contents.length();
              osw.write( contents , 0 , length );
              osw.flush();
              osw.close();
              fos.close();
              return tempFile;
         public void executeFile( File file )
              throws InterruptedException , IOException
              String filePath = file.getAbsolutePath();
              System.out.println( "File path: " + filePath );
              Runtime runtime = Runtime.getRuntime();
              //Actual system permission.     
              Process process_perm = runtime.exec( "chmod +x " + filePath );
              int exitValue = process_perm.waitFor();
              System.out.println( "chmod +x exit value: " + exitValue );
              //Execute the file.
              Process process_exec = runtime.exec( filePath );
              exitValue = process_exec.waitFor();
              System.out.println( "Executing file: " + exitValue );

  • Getting my HP Officejet Pro to do other functions in Linux

    I use a debian distro of Linux as the primary OS, the printing part works fine, it's all the other functions that don't.
    How do I get the scan to file, email, etc. to work with the Linux OS?

    Ctopkis, Make sure you have updated your firmware. Here is the link to the lastest firmware that was posted on 02-18-2012. 
    Firmware upgrade is for HP Officejet Pro 8100 ePrinter - N811a
    Post back and let me know if this fixes the issue or not.
    -Sean
    -------------How do I give Kudos? | How do I mark a post as Solved? --------------------------------------------------------

  • Runtime.getRuntime().exec problem with linux script.

    Hello,
    I try to start a script under Linux RedHat 9. This script must just create another file.
    I work with JDK 1.4.1_02b06.
    If I use the next command
    process = Runtime.getRuntime().exec("/temp/myScript.sh");
    This is not working. I script file is existing otherwise I receive an error. I don't understand why the script is not executed!
    I have check some other posts in this forum but I cannot find the solution.
    Thanks in advance for your help.
    Alain.

    Try running it with sh: Runtime.getRuntime().exec("sh /temp/myScript.sh");

  • Exec function in package with ADOdb - howto

    Hello Users,
    here is a 10.2 SE Oracle on a Linux. From an another machine I connect to them from PHP, through ADOdb. Most of query's work, but here are many packages, which have functions and procedures.
    I try to execute a function in a package:
    $stmt = $db->PrepareSP("
    declare chkpass varchar2(255); BEGIN chkpass := ACCESS.check_pass('user', 'secret'); END;");
    $out = "";
    $db->OutParameter($stmt, $out, 'chkpass');
    but PHP says:
    OutParameter($stmt, $php_var='', $name='chkpass', $maxLen=4000, $type=false);
    Bind: name = chkpass
    Warning: ocibindbyname() [function.ocibindbyname]: ORA-01036: illegal variable name/number in
    /path/to/adodb/drivers/adodb-oci8.inc.php on line 921
    (oci8): declare chkpass varchar2(255); BEGIN chkpass := ACCESS.check_pass('user', 'secret'); END;
    What is the better way to handle the procedures/functions in packages?
    (that package gets two params: login and password, and gives back a single char, one of these three value: 'U', 'I', 'N')
    Thank you:
    a.

    Perhaps something like this?
    Also see http://phplens.com/lens/adodb/docs-oracle.htm
    <?php
    create or replace function data_func(p1 in varchar2, p2 in varchar2) return varchar2 is
    begin
    return p1 || p2;
    end;
    require_once("adodb.inc.php");
    $db = NewADOConnection("oci8");
    $db->Connect('localhost/XE', "hr", "hrpwd");
    $stmt = $db->PrepareSP("begin :ret := data_func(:a1, :a2); end;");
    $input1 = 'first';
    $input2 = 'second';
    $db->InParameter($stmt, $input1,'a1');
    $db->InParameter($stmt, $input2,'a2');
    $db->OutParameter($stmt, $ret, 'ret');
    $ok = $db->Execute($stmt);
    echo "Function ";
    if ($ok) {
         echo "OK $ret";
    } else {
         echo "Failed";
         var_dump($$db->ErrorMsg());
    echo "\n";
    ?>

  • GetRuntime().exec problem under Linux

    Here's a piece of code under Mandrake.
                Process p;
                try
                    p=Runtime.getRuntime().exec("/usr/local/WordNet-3.0/bin/./wn " + englishword + " -hypen > /home/istvan/wordnet/Kimenetek/ki.txt"); //"englishword" is a String
                    //p=Runtime.getRuntime().exec("ls");
                    try {p.waitFor();}
                       catch (InterruptedException ex1) {System.out.println(ex1.getMessage());}
                    System.out.println(p.getInputStream().toString()); // ---> "java.io.BufferedInputStream@1bcc0bc"
                    System.out.println(p.getErrorStream().toString()); // ---> "java.io.FileInputStream@111a3a4"
                   catch (IOException ex) {System.out.println(ex.getMessage());} It does absolutely nothing, doesn't create the desired "ki.txt" file, although from the command line works just fine. In fact, even at the simple "ls" command gives the message mentioned in the code as a comment.
    Can somebody help me? Thanks in advance.

    There are several problems.
    First of all, the "command > somefile" syntax is interpreted by
    the shell on Linux. But exec does not load the shell by default.
    So the redirection does not work.
    Secondly, you should not execute the program as is,
    and then read its output using "getInputStream()" afterwards.
    There is buffer overflow and data starvation issues.
    See this excellent tutorial for how to create separate
    threads to channel data to and from a subprocess:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Runtime exec to run linux scripts

    Hi,
    I have been having trouble running a simple linux script from within my java program. So far, this is the command line i am passing to the exec() method:
    String[] commandArray = {"/bin/sh", "-c", "sh",
    "/home/charles/java/ideaProjects/Condor/linuxScripts/LinuxSubmit.sh",
    "TwoMinTest.cmd"};
    Process proc = rt.exec(commandArray);
    The last paramater, "TwoMinTest.cmd" is a varibale that is passed to the script. The command works fine from a linux terminal window but from the java program the process just hangs with no out put from the script (the script does an echo "hello" first). Both the error and input streams obtained from the process do not output anything. If i instert a deliberate mistake into the command the error stream outputs it fine. Any idea why it hangs?
    thanks, Charles

    I've fixed it for anyone who's interested, this is what i did:
    String[] commandArray = {"/bin/sh", "-c", "sh"};
    Process proc = rt.exec(commandArray);
    OutputStream out = proc.getOutputStream();
    PrintWriter p = new PrintWriter(out);
    p.println("sh /home/charles/java/ideaProjects/Condor/linuxScripts/LinuxSubmit.sh " +
    "TwoMinTest.cmd");
    p.flush();
    and it flew like a bird.
    charles

  • Runtime.exec() problem with Linux

    Hi All,
    I have a java program which I am using to launch java programs on all platforms.
    I am using the Runtime.exec() method to start the process in a separate JVM.
    But, I had a problem with the -classpath switch if the directories contained spaces. So I modified the java command which I am passing to the exec() method to something like:
    java -classpath \"./my dir with spaces\" com.harshal.MainThis I had to do because of the problem in windows. But, if I use double quotes in Linux (for the classpath switch in my exec() method), it won't work.
    Can anyone correct me so that I can use the Runtime.exec() method on all platforms to launch the java application even if the classpath directories contains spaces.
    Thank you very much.

    I was reading about the command line args on java's
    tutorial and I found a shocking news. Mac OS doesn't
    support command line args, That's news to me. Could you please elaborate ?
    More important is: I got it working. I figured out I had forgotten to try something before, or, to be more correct, I made an error when trying malcommc's envp suggestion: I used "classpath" as key, not "CLASSPATH", as it should have been.
    Ran a new test, got it working.
    Sample:
    Given a rootdir. Subdirectory "cp test" with a classfile (named "test") without package declaration. Running another class in another directory, using:
    String[] cmd = new String[]{
        "java", "test"
    String[] envp = new String[]{
        "CLASSPATH=rootdir:rootdir/cp test" // <-- without quotes.
    Runtime.getRuntime().exec(cmd, envp);It's been my wrong all the time. I didn't check hard enough. It simply had to work somehow (that's the kind of things that's easy to say afterwards :-)).

  • How to install Oracle 10g with its grid functionality on Linux?

    Well, I thought changing the subject line might help to convey the meaning of what I want better. Here's my earlier post from a few hours earlier.
    Hi,
    I need carry out TPC-C benchmarking test for Oracle 10g (using one, two and four servers; basically using the grid in case of multiple servers). I have installed oracle 10g (with default options) on all the four servers, but beyond that I have no idea as to how can I invoke the grid option in order to carry out the tests-by my statement, I mean do I need to choose grid option while installing Oracle or is it the case that I specify the grid option in the code that I write for carrying out the tests. The OS is LInux (Scientific Linux).
    An unrelated problem-one of the servers is 64 bit while others are 32 bit, and proper versions of oracle have been installed. Neglecting the obvious fact that this will make comparisons difficult does anyone anticipate any other problem?
    Many Thanks!
    Steve
    *******************************************************************************************************

    Do you think that the installation of RAC can be done
    in a week? yes, as long as you know what you are doing and can catch the concept quickly and good at following instructions.
    Moreover, we do not have a cluster-all we
    have are four servers that are separate. Do you know
    if the name Real Application Clusters implies that
    the servers have to be in a cluster?
    The basic idea of RAC is all these hosts need to share same set of storage. The most popular such storage are SAN and NAS.
    An example of building RAC on linux
    http://www.oracle.com/technology/pub/articles/hunter_rac10gr2_iscsi.html

  • How to Use Exec function in Java Code

    How to Use Exec method
    I want to Execute command
    net Start "some service"
    using exec method of runtime class
    or i use some other way if suggest

    Assuming you have read http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html#exec(java.lang.String) already, I can only suggest to be more specific in what your problems are. If you are after just some example code, then download ftp://ftp.ebi.ac.uk/pub/software/textmining/monq/monq.tar.gz and have a look at the source code of monq.stuff.Exec. It does all those things which are necessary to keep track of a Process after it was created with exec.
    Harald.
    BioMed Information Extraction: http://www.ebi.ac.uk/Rebholz-srv/whatizit

  • About:home search does not function in Linux Mint 15

    I installed a fresh copy of Linux Mint 15 (Cinnemon) recently. It comes pre-packaged with Firefox, but after setting the homepage back to the default (about:home), I noticed that the search bar on that page wasn't working. By that I mean the form does not submit neither by pressing Enter or clicking the "Search" button.
    I've removed all add-ons, removed and reinstalled Firefox a few times, tried the Reset feature, deleted and recreated profiles, manually reset config options to default, and anything else I could think of. Nothing has helped.
    Some users with a similar issue have mentioned that deleted chromeappsstore.sqlite helped, but this file is never even created for me. Additionally, localStorage["search-engine"] is undefined according to the console, yet Google is set as the defaultenginename.
    Any ideas on what else to try?

    The SearchReset only resets the involved prefs.<br />
    If the actual search engines are missing then the extension won't help.
    Current Firefox versions use the default search engine (pref: browser.search.defaultenginename) to set the search engine that is used on the about:home page.
    *browser.search.defaultenginename
    Currently selected search engine:
    *browser.search.selectedEngine

  • System exec function

    could someone give me a hint as to what the 'expected output size'
    input on System Exec refers to? I'm using it to run another program
    which will download some data for me to work on with labview. I dont
    expect it has anything to do with the file size of that data?
    Also, is there a way I can tell when the program I have called has run
    to completion? Or can i just use the 'run to completion' boolean to
    prevent the next part of the VI executing before the data has finished
    downloading?
    Thanks, Paul.S

    "mechatron" wrote in message
    news:[email protected]..
    > could someone give me a hint as to what the 'expected output size'
    > input on System Exec refers to? I'm using it to run another program
    > which will download some data for me to work on with labview. I dont
    > expect it has anything to do with the file size of that data?
    A called program might pass some information, but when the application
    terminates, the memory with this information is released. So, the program
    passes a pointer to a string, but the memory it points to is removed.
    To prevent this, the caller passes a pointer to a buffer, and the program
    fills this buffer. Then it passes the same pointer back, and the caller can
    read the message in it's
    own memory. This buffer needs to be large enough.
    If the program don't pass anything (you don't expect anything), just put the
    "expected output size" on the default value. A buffer that is to big can't
    do any harm.
    > Also, is there a way I can tell when the program I have called has run
    > to completion? Or can i just use the 'run to completion' boolean to
    > prevent the next part of the VI executing before the data has finished
    > downloading?
    Yes, that's what is it for.
    > Thanks, Paul.S

  • Inconsistent Return Code from exec on RedHat Linux

    I am calling a simple command from the RunTime exec.
    /bin/cp file1 file2 file3
    This should fail and it returns a two line stderr output. The problem is that it also returns an exitValue of 0. When run from the shell, it always returns 1. Any idea where the "1" is going to under Java?
    I have seen it return the 1 on about 2 of 10 tries. The inconsistent return is also curious to me.

    I did use waitFor. After searching through the bug reports, I found that it is an actual bug that was in 1.4.1_02. I downloaded 1.4.2 beta and they have fixed the problem there.
    Thanks for you input

Maybe you are looking for

  • Problem in Data Grid

    Hi All, Account calculations are not displaying on the data grid. But the values are being picked up with a smart view report. I tried running a force calculate and a consolidate all, but that did not work. Please suggest in this regards. Thanks in a

  • I can't install and run flash player on my O.S. GNU/linux

    sorry, i'm new user this system, but need know how to complete installation of adobe flash player on my computer. O.S.(i686 GNU/Linux). thanks!

  • In Purchase order history is not showing the Reversal of goods price

    Hello friends, I have created a PO , for that i have done the GR and invoice. Now i want to reverse the goods using MType-102, for that i have created the credit memo . I have done the reverse GR ,But in Purchase order history the For the GR reversed

  • Leopard general issues (slow boot-Blue screen of tolerance)?

    I upgraded it to leopard 10.5.2 a week ago. I thought my old system with tiger (10.4.11) used to boot faster and work faster and I thought I was being cynical. I just checked with my buddy's computer which is completely identical to mine (2GHz intel

  • PDF on Preview only sharp during scrolling

    Hello, I use Yosemite and Preview for reading PDFs. I have this issue, that whenever I scroll the pages in single side or double side mode the font gets much sharper than when I do not touch the trackpad.  In continuous scrolling mode, even when zoom