Hi, this is going to sound like a pointless question since it should be easily tested myself, but here me out first.
Can you use the following command in a C program to run a batch file in Linux?
system("example.bat");
I can't test it out myself since I'm ssh'ing into a linux server remotely from my windows computer, and the server blocks me from doing stuff with a batch. I could also seemingly just wait til Monday when I can use a school computer, but time is of the essence and I really need to know that it works before then.
you can run the unix version, a shell script, using system. If the security prevents it, you cannot, though. It would be very odd to do that on unix; the os still relies on scripts and console programming at its core and blocking that would mean you have a useless unix shell. I don't think the os can tell between the program calling it and you calling it, is why.... and they *have* to let all but the most untrusted users run scripts.
I have no choice but to go to college after hours and test it on their machines then.
It'll either work for me or I have something wrong in the code. There's all sorts of student rights about fair challenges, and assigning something we have no way of testing would break pretty much all of them.
Side note, I have never felt much like a computer scientist til we started working in terminal. Makes you feel good when stuff happens.
Hey, so. I misunderstood the instructions. The simulated shell is to have 2 modes: interactive and batch. When it said user choice, I assumed you programmatically made a menu where the user got to choose 1 for interactive, 2 for batch.
That was wrong. I wasn't aware that you can have a c program program.c and a batch file ba.sh
and be able to do ./program ba
...or is it ./program ba.sh?
I'll have to tinker to be sure. Anyhow, the user chooses by how they run it on the command line.
*edit*
./program ba.sh
I wondered why he wanted us to have a main with arguments. This explains it.