Results 1 to 5 of 5

Thread: Running a bash script from resource (qrc) file

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2012
    Posts
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Maemo/MeeGo

    Default Re: Running a bash script from resource (qrc) file

    Quote Originally Posted by yeye_olive View Post
    I suppose you could start bash in interactive mode and dump the script on its standard input, but this would be ugly, error-prone, and you would have to use the native API since QProcess only allows you to redirect the standard input to a file, not an arbitrary QIODevice.
    Perhaps ugly, but that seams to work:

    Qt Code:
    1. QProcess *proc = new QProcess;
    2. QString name = "/bin/bash";
    3. arg << "-c" ;
    4.  
    5. QFile file(":/test.sh");
    6. if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
    7. return 42;
    8.  
    9. arg << file.readAll();
    10. proc->start(name, arg);
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to spark82 for this useful post:

    TheIndependentAquarius (16th December 2015)

Similar Threads

  1. Running an script using QProcess
    By DiegoTc in forum Newbie
    Replies: 1
    Last Post: 31st December 2010, 18:02
  2. Running java script in QtWebKit makes GUI sluggish
    By calium in forum Qt Programming
    Replies: 0
    Last Post: 26th August 2010, 09:35
  3. Running shell script with as super user in N900
    By spylvas in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 30th April 2010, 01:05
  4. Resource file in Qt4.4.0
    By jml in forum Qt Tools
    Replies: 0
    Last Post: 6th May 2008, 18:01
  5. Resource file in a lib
    By Rodrigo in forum Qt Programming
    Replies: 4
    Last Post: 25th June 2007, 15:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.