0

I am making an FTP in C for learning purposes. I know how to connect to a computer and read/write a file, but I'm having problems with running programs. My idea is to connect to the computer, cd into a directory called Available and run ls -l or dir depending on what type of operating system the computer the client has connected to has. After I run one of the commands I want to be able to list the results on the client's computer. My question is, is this possible and if so what would I do? Thank you for reading.

Mischa Arefiev
  • 5,227
  • 4
  • 26
  • 34
D347th
  • 697
  • 1
  • 10
  • 16

1 Answers1

2

Don't run console commands like that. Use the operating system's API / system calls to enumerate files in the current directory.

Windows: FindFirst/FindNextFile APIs Linux: http://www.cs.cf.ac.uk/Dave/C/node20.html#SECTION002000000000000000000 <-- this should help for linux

  • Will this display the other computer's files on the client's computer or what specifically will it do? – D347th Jan 26 '12 at 18:26
  • Enumerate the files. Send it back through a socket to the other computer. Display the information in whatever manner you wish. –  Jan 26 '12 at 19:13