Hi I have a shell script which executes some commands, when I invoke that script using terminal it works fine but when I invoke the script using a QProess few commands doesn't works well.
Here is the script
#!/bin/bash
echo "Invoking the script"
euid=$1
if [ $# -ne 1 ]; then
echo "Arguments missing"
exit 1
fi
echo "arg 1: $1"
data=$1;
name=$(echo $data | cut -b 1-7)
age= $(echo $data | cut -b 10-11)
echo "$name"
echo "$age"
Here is the way I use QProcess
// Environment setup
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
candidateProcess->setProcessEnvironment(env);
QString script("/home/root/scripts/getInfo.sh");
candidateProcess->start("/bin/bash", QStringList() << script << qwertyuand21");
If I run this script in shell It works fine, get the value of name and age. But when I invoke the script from Qt using the above stated method I get error for cut command, First 3 echo works well, then I get error for the cut command as cut : command not found
and then nothing comes up for the echo commands because cut command failed.
What is the reason for that? I have provided shell for the process but still these errors??