I have created a script that takes a file(FiletoModify.txt) and copy line by line everything it contains to a new txt file which I called it output.txt.My problem is that I want to call system to do the following in my code but it doesn't work.I'm a new in C programming and I'm making it clear that I can't see my mistake and I really need some help.Thank you
My code in my C program:
system("cd Desktop; chmod +x script.sh ; ./script.sh");
Here's the script code:
#!/bin/bash
while IFS= read -r line
do
echo "$line"
echo -e "$line\n" >>output.txt
done <"FiletoModify"
\tto a tab character, for instance, or\nto an extra newline. Don't useecho -e(which is also non-POSIX);printf '%s\n' "$line"is your friend.system()at all? You can callchdir(),chmod(), etc., from C -- which is faster and doesn't open you up to bugs like shellshock.//in your original code? For a shebang to work, the#!need to be the literal first two characters of the file; you can't have anything else before them.