0

I am using Qt 5.0.1 (64 bit) in ubuntu. I am running the following command under button pressed function.

QString command = "sh /home/rahul/qtapp/ques_new/ques_new/inter4ql/test1.sh"; const char* command2;

command2 = command.toLocal8Bit().data();

system(command2);

test1.sh file content is

!/bin/bash

echo "hello" echo "hello" >> out.txt


While calling this system command by pressing button, it shows hello in the output window, but it doesnot create new file out.txt.

For debugging I manually create out.txt before calling this function. But, after calling this function again it shows hello on output window but doesnot put hello in out.txt.

latonz
  • 1,601
  • 10
  • 21

1 Answers1

1

Your code is wrong.

Try:

#!/bin/bash
echo "hello" >> out.txt

Worked without any problems here.

Also, the file might not being created at directory you're looking at. Have you checked your script directory and your application working directory? Replace the out.txt with a full path (/home/derp/out.txt, for example).