How to append linux shell command output to MariaDB?

That link gave me an idea, I can create an .sql template file with the "insert" query, dump the shell command output to a text file (>), then use "grep" and "sed" to append the desired parts of the command's output file to that .sql file and then execute the .sql file. What do you think?

I haven't done this myself, but it is probably something along the lines of the answer provided in this link:
http://stackoverflow.com/questions/3900496/using-shell-script-to-insert-data-into-remote-mysql-datab...


Similar Messages

  • How to execute a shell command in java?

    here, my environment is redhat 7, jdk 1.5.
    i don't know how to use the shell command in java.
    i want to use this function:
    #include <stdlib.h>
    int system(const char * string);
    please give me some ideas. and Thank you so much if coming with a little demo.

    i know i should use JNI. because i have to use C lib.
    but i have already use JNI to wrapper the original code the cpp code and java code is :
    //: appendixb:UseObjImpl.cpp
    //# Tested with VC++ & BC++. Include path must
    //# be adjusted to find the JNI headers. See
    //# the makefile for this chapter (in the
    //# downloadable source code) for an example.
    #include <jni.h>
    #include <stdlib.h>
    extern "C" JNIEXPORT void JNICALL
    Java_UseObjects_changeObject(
    JNIEnv* env, jobject, jobject obj) {
    jclass cls = env->GetObjectClass(obj);
    jfieldID fid = env->GetFieldID(
    cls, "aValue", "I");
    jmethodID mid = env->GetMethodID(
    cls, "divByTwo", "()V");
    int value = env->GetIntField(obj, fid);
    printf("Native: %d\n", value);
    env->SetIntField(obj, fid, 6);
    env->CallVoidMethod(obj, mid);
    value = env->GetIntField(obj, fid);
    system("preprocess -path sha.c");
    printf("Native: %d\n", value);
    } ///:~
    //: appendixb:UseObjects.java
    // From 'Thinking in Java, 2nd ed.' by Bruce Eckel
    // www.BruceEckel.com. See copyright notice in CopyRight.txt.
    class MyJavaClass {
    public int aValue;
    public void divByTwo() { aValue /= 2; }
    public class UseObjects {
    private native void
    changeObject(MyJavaClass obj);
    static {
    // System.loadLibrary("UseObjImpl");
    // Linux hack, if you can't get your library
    // path set in your environment:
    System.load(
    "/root/jproj/UseObjImpl.so");
    public static void main(String[] args) {
    UseObjects app = new UseObjects();
    MyJavaClass anObj = new MyJavaClass();
    anObj.aValue = 2;
    app.changeObject(anObj);
    System.out.println("Java: " + anObj.aValue);
    } ///:~
    i modify this two file which is from TIJ-2edition.
    the output is
    Native: 2
    Native: 3
    Java: 3
    but what i want to be executed "preprocess -path sha.c" does not work.
    i have change the command to, such as "df", "ls" etc. but none of them works
    please help me.

  • How can i call shell command in JSP?

    My OS is Linux, and my WWW server is Tomcat,
    can i call shell command , such as gcc or setup,
    If yes, how can i? Would you give a source example?
    Thank you!

    Hi,
    I did this simple class to launch a process and after the cose there is an example to use it:
    import java.io.*;
    import java.util.*;
    public class ProcessExec {
    private String[] command;
    private StreamGobbler errorGobbler;
    private StreamGobbler outputGobbler;
    public ProcessExec() {
    public ProcessExec ( String[] command) {
    this.command = command;
    this.errorGobbler = null;
    this.outputGobbler = null;
    public String[] getCommand() {
    return ( this.command );
    public void setCommand( String[] command ) {
    this.command = command;
    public void exec() {
    try{
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(this.command);
    // any error message?
    errorGobbler = new StreamGobbler(proc.getErrorStream(), "ERROR");
    // any output?
    outputGobbler = new StreamGobbler(proc.getInputStream(), "OUTPUT");
    // kick them off
    errorGobbler.start();
    outputGobbler.start();
    }catch (Throwable t){
    t.printStackTrace();
    }//catch
    public String getErrorMessage() {
    while ( this.errorGobbler.isAlive() ) {;}
    return ( this.errorGobbler.getResult().toString() );
    public String getOutputMessage() {
    while ( this.outputGobbler.isAlive() ) {;}
    return ( this.outputGobbler.getResult().toString() );
    } // ProcessExec
    Example to use it:
    try {
    ProcessExec pe = new ProcessExec( command );
    pe.exec();
    errorMessage = pe.getErrorMessage();
    outputMessage = pe.getOutputMessage();
    } catch ( Exception e ) {
    System.out.println (e);
    As you can guess the string "command" must be the command you have to launch and errorMessage and outputMessage will contain the error and the output that the process will generate.
    Try it; i hope this will help you.
    Cheers.
    Stefano

  • How to execute a shell command?

    What class and method should I use to set an environment variable on a local system? And how do I execute a shell command in Java?
    Thanks!

    I don't know about setting environment variables from java, but I do know how to execute system commands (and from there you could modify environment variables).
    Use Runtime.getRuntime().exec()
    There are quite a few pitfalls with using this though...
    1. It's platform dependent
    2. Doing this creates a Process. If this process has output, you need to read this, otherwise the output buffer will overflow, and that would be bad... Input is not so bad (either supplying it or not ;)
    3. If you use Win for example, and want to do a "dir", there are complications, as there is no dir.exe file, and hence it can't be executed... Do a search for this topic, there's plenty on how to get around it.
    Anyway, there's plenty more info on Runtime.getRuntime().exec(), have a look around.
    Cheers,
    Radish21

  • How to execute linux sh command from inside CF

    I am using CFMX 7,0,0,91690 Enterprise on Redhat Enterprise Linux 4.9 with Apache webserver 2.0.52.  I have a coldfusion template that queries from a Postgresql 8.0 database, copies the data from the queries into a set of files in one folder on the linux server, and then has a CFEXECUTE tag at the very end that calls a bash shell script on the same server. The shell script takes the files from the one folder, merges some of their content together, moves them to another folder, adds header and footer, and sets ownership and permissions.  These 2 scripts have been in place and working perfectly for several years now. No changes were made to content, permissions, or ownershop of scripts.  Suddenly last Friday the coldfusion script seems to have lost its ability to execute the shell script properly.  It does execute it and the shell script attempts to do some of the steps, but the resulting files are missing the content and have the linux environmental variables and their values displayed instead.  Clearly its getting an error but that is not being reported back to me. After the CF script ends, if I manually execute the shell script from the linux command line, it works perfectly. I tried giving it more permissions but that did not help.  Redhat support suggests I run the script with "sh -x" to get more detailed output for debugging, but I would need to do that from inside the CF script since that is where the problem is.  Is it possible to execute a shell script from inside a CF script using a linux "sh" command in some way (instead of the cfexecute, just so I can see debugging info)? Thanks in advance for any suggestions. Julie

    Thanks for the suggestion, tried that too:
    <cfexecute name="/bin/sh" arguments="-x /bin/siscopy" outputfile="/home/coldfusion/sh_output.txt" timeout="600" />
    still didn't work.  Script ends with this coldfusion error:  Timeout period expired without completion of /bin/sh
    It does not complete the task of making the files, and the sh_output.txt file which is supposed to capture the -x output, is empty.
    Thanks,
    Julie

  • ProcessBuilder Shell Command Output

    When using ProcessBuilder to execute a shell command, certain output seems to be suppressed, for instance:
    ProcessBuilder pb = new ProcessBuilder("ls", "*.java");
    Process ps = pb.start();
    Scanner in = new Scanner(ps.getInputStream());
    while(in.hasNextLine())
              System.out.println(in.nextLine()); // produces no outputFor some reason, this produces no output, even if there are java files in the current directory. If I remove the argument "*.java", then I will get output such as:
    Main.java
    Main.class
    Other.java
    Other.class
    Any idea why I don't get output from filtering my list?

    However, executing sh -c ls *.java doesn't actually filter the listingsThat's not correct.
    so everything is outputted whether it matches the pattern or not.Nor that.
    I suppose I can handle the it though, somehow else.It should work as expected. If it doesn't you have done it wrong.

  • How to Execute Power Shell Command From Windows Application.

    Hi All Experts,
    I want to execute power shell commands from my windows application.
    Is it possible ?
    Please let me know your comments..
    Thanks.

    I have not tried this, but apprently it is easy as in the sample pasted below. please see this article for more details
    http://geekswithblogs.net/Norgean/archive/2012/09/19/running-powershell-from-within-sharepoint.aspx.
    Let me know how it goes...
    public string RunPowershell(string powershellText, SPWeb web, string param1, string param2) {
    // Powershell ~= RunspaceFactory - i.e. Create a powershell context
    var runspace = RunspaceFactory.CreateRunspace();
    var resultString = new StringBuilder();
    try
    // load the SharePoint snapin - Note: you cannot do this in the script itself (i.e. add-pssnapin etc does not work)
    PSSnapInException snapInError;
    runspace.RunspaceConfiguration.AddPSSnapIn("Microsoft.SharePoint.PowerShell", out snapInError);
    runspace.Open();
    // set a web variable.
    runspace.SessionStateProxy.SetVariable("webContext", web);
    // and some user defined parameters
    runspace.SessionStateProxy.SetVariable("param1", param1);
    runspace.SessionStateProxy.SetVariable("param2", param2);
    var pipeline = runspace.CreatePipeline();
    pipeline.Commands.AddScript(powershellText);
    // add a "return" variable
    pipeline.Commands.Add("Out-String");
    // execute!
    var results = pipeline.Invoke();
    // convert the script result into a single string
    foreach (PSObject obj in results)
    resultString.AppendLine(obj.ToString());
    finally
    // close the runspace
    runspace.Close();
    // consider logging the result. Or something.
    return resultString.ToString();
    Ok. We've written some code. Let us test it.
    var runner = new PowershellRunner();
    runner.RunPowershellScript(@"
    $web = Get-SPWeb 'http://server/web' # or $webContext
    $web.Title = $param1
    $web.Update()
    $web.Dispose()
    ", null, "New title", "not used");
    -Sangeetha

  • How to execute Linux OS command  from ODI

    We have installed Oracle data integrator on windows machine and want to execute linux OS command in a procedure or scenario from ODI .
    How could i do that ?
    I can see os command elements but they do not work, only windows commands work.There should be linux technology i think

    Obviously you can execute Unix OS commands only on Unix OS. Why do you expect Windows to understand it?
    The solution in your case would be executing your ODI scenarios with an Agent installed on Unix machine.
    Cheers

  • Linux shell commands through linux

    i am trying to run shell comands through java.
    so far i hav been success ful in running some of them. but when ever a '\' symbol is encountered it doesnt work.
    i use
    process p = Runtime.getRuntime().exec(command)
    example
    command= "mount -t smbfs //192.168.10.150/abcd /home/lan" works fine
    but "mount -t smbfs //192.168.10.34/english\\ songs /home/lan"
    does not work
    is there a way to bypass writing a shell script and executing it?
    i just want to execute it directly without writing it in a shell file first.

    yes there are spaces in the path name thats why im using '\'. and yes in the string i do write it as '\\'. it displays the correct path name using println in the terminal but doesnt run using exec(). im aware of the temp.sh way and i know it works but im working on a networking project and want to avoid writing to a file again and again.
    the other constructor of exec seems interesting. ill try it.

  • How to use the SHELL command

    I simply want to open NOTEPAD and automatically load a specified file for modification. I would like it to automatically become active (not minimized).
    My code: 'Shell ("C:\WINDOWS\NOTEPAD.EXE", Fname)'. I also tried 'i =
    Shell ("C:\WINDOWS\NOTEPAD.EXE", Fname)'.
    Both ways produce the error "InvalidCastException".

    Hello,
    Thank you for your post.
    I am afraid that the issue is out of support range of VS General Question forum which mainly discusses
    WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System
    and Visual Studio Editor.
    I am moving your question to the moderator forum ("Where is the forum for..?"). The owner of the forum will direct you to a right forum.
    Best regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to Save Command Output to Flash on ASA 8.4

    Hi,
    I nice easy one for you guys.
    How do you save the command output from the CLI  to a file on flash?
    With IOS, I would normally use a pipe command to redirect to tftp, but the ASA doesn't support this as far as I can tell. As a work around I was thinking I could save the output to flash and then tftp that file off the ASA.
    Thanks,
    Paul

    Hi Jennifer,
    Thanks for your help. I do use this feature at the moment, but I find every break in the output (where you need to hit space to see more) gets recorded which leaves the file quite messy. I usually have to edit the file afterwards so it reads clearly.
    I wondered if there is a way for the asa to write the output directly?
    Thanks,
    Paul

  • How do I run a snmpwalk/any bash command as a Linux/Unix command (2 state monitor) on a Isilon storage device

    Is there a way that I can run a snmpwalk / isi devices (to find the status of the disk drives in islon) / any Linux bash command using a 2 state monitor Unix/Linux shell command and target a storage device (Isilon in my case) and not target a Unix/Linux
    machine. I tried creating one and it complained saying,
    Is there a way I could run a bash command in my isilon storage and use the ouput to determine the state of the monitor? Please let me know
    Hari V

    For Unix/Linux shell command in Operation Manager to monitor 2 state, you can refer to below link
    http://contoso.se/blog/?p=2680
    http://stefanroth.net/2012/10/21/scom-2012-linux-two-state-monitor-with-script-in-script/
    http://operatingquadrant.com/2012/02/01/opsmgr-2012-unixlinux-authoring-templates-more-information-on-the-shell-command-templates/#more-746
    Please remember, if you see a post that helped you please click (Vote As Helpful" and if it answered your question, please click (Mark As Answer).

  • Execute shell command from Java

    Hi all,
    I need some idea for executing shell script from Java programe.
    For example i have start.sh script in /tmp/start.sh  folder of unix server.
    I want to execute shell script from local java code.
    Any idea on this.

    Hi,
           Read the following articles/posts, maybe this could help you:
          How to execute shell command from Java
    Running system commands in Java applications | java exec example | alvinalexander.com
    Want to invoke a linux shell command from Java - Stack Overflow

  • Running shell commands in pre-post session commands

    Hi Nikita: It depends on what kind of OS your Secure Agent is running on. If you're running your Secure Agent on Windows, you can enter DOS commands into these fields which may include SQL scripts using batch files. Similarly, if you're running your Secure Agent on Linux you can enter shell commands which may include SQL scripts using shell scripts. You should be able to find some examples of these commands from other Informatica Cloud users by searching the Community. Hope this helps,Josh

    Hi all,I am new to informatica, can anyone please explain me how should i run shell commands in pre/post session commands?and what type of shell scripting is usually needed for the informatica jobs? Thank you

  • Calling Shell commands in C programme

    How would i call shell command using C programme.

    #include <unistd.h>
    #include <sys/types.h>
    #include <stdlib.h>
    #include <sys/types.h>
    #include <wait.h>
    int main(void) {
    pid_t pid;
    pid = fork();
    if (pid == 0) {
    execl("/bin/sh", "sh", "-c", "/bin/ls -l > /tmp/ls", NULL);
    exit(1);
    else if (pid > 0) {
    wait(NULL);
    else {
    return -1;
    return 0;
    }

Maybe you are looking for

  • Calling web service via utl_dbws with unbounded return values

    Hello, everyone. I'm trying to use utl_dbws to call web service from Oracle DB 10 g. WS has unbounded return value: <xs:element maxOccurs='unbounded' minOccurs='0' name='return' type='xs:string'/> I'm setting return paramter in web service call handl

  • Airport Extreme and connecting a hard drive

    Hello All, Thank you ahead of time for your help! I have a couple of questions regarding the set up of my airport extreme and an external hard drive. What I want to accomplish is using the airport extreme to ONLY share a hard drive for backup and sha

  • Need info and help with ARD

    I would really like to get some information and help that would enable me to troubleshoot my mother's new Mac Mini for her. She lives in CA and I live in WA. She is new to Macs and I just KNOW there will be lots of desperate phone calls from her to m

  • EPMExecuteAPI error in excel input form

    Hello expert, I'd like to add an EPMExecuteAPI link in an Excel input form, but I get an error in the cell : #Error - Unexpected Error. Check your parameters. Here is the formula I set in the cell : =EPMExecuteAPI("DataManagerOpenViewStatusDialog";"V

  • Illustrator CS4 error: Object label badly formatted?

    has anyone received an error in illustrator CS4: Acrobat PDF File Format is having difficulties. Object label badly formatted? I am ON a mac and cannot open files after this error, help?