Reputation: 495
I am trying to create a file using the system command but it does not work for some reason. It just echoes the command back.
system("echo 'Hello2222, world.' >foo2.txt");
Hello2222, world. >foo2.txt
When I run the echo command in CMD, the file is created.
Upvotes: 2
Views: 432
Reputation: 37641
Notice that the documentation for system
says
On Windows, system does not use a shell and there is a separate function shell which passes command lines to a shell.
shell("echo 'Hello2222, world.' >foo2.txt")
will do what you want.
Upvotes: 3