#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    florida
    Posts
    39
    Rep Power
    12

    manipulating files stored on a website


    I'm using borland C++ 4.5
    I need a program to run on my pc, but it needs to be able to read and write files that are stored on my website (on a server, not my own pc).
    I would like to be able to do this directly, as well as using the C program to run cgi scripts on my site and pass variables back and forth.
    Is it possible to do this with the C language I'm using? If it is how do I make the connections?
    Thanks :)
    John
  2. #2
  3. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    244
    It is not as simple as opening a file, unless, of course, you obtain a library that allows that. You will have to open a socket to the server program (keep in mind that ANYONE can open the same socket, so you have a massive security hole unless you want to learn about cryptology and authentication), make a request to the server via the socket (since it is just a bunch of bits going back and forth, you get to invent your own protocol), then return the bits from the file on the server. It is not terribly complicated, but you do need to understand sockets pretty well as well as TCP/IP. There are programming APIs you can use, such as NFS, Netbui, etc. All with varying degrees of (or lack of) security. When you attach a server to a port on a computer connected to the Internet, you are really letting your pants down. Using CGI to accomplish the same thing does not provide any additonal security, just an additional layer of abstraction.

    Have you considered FTP? Or its secure cousin SFTP?

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    florida
    Posts
    39
    Rep Power
    12
    ftp could work but I have no clue how to connect to ftp from C either. and I would still need to be able to run cgi scripts on the server from the program. I'm thinking passing arguments wouldn't be necessary if I can read and write the files in the C program. I'm wondering if I can call internet explorer from the C program using the address to the cgi as an arguement. if I can do this then that only leaves the matter of transfering files, ftp would work for that if you can tell me how to connect to ftp in C
    Thanks :)
    John
  6. #4
  7. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    244
    I have solved the 'ftp problem' by calling batch files from my programs. As for doing CGI, you can execute CGI scripts just like downloading a web page in C code, but of course, you need to know socket programming. Windows has a bunch of APIs that greatly simplify the need to know low-level detail. Look up the afxinet header file and the classes CInternetSession, CHttpConnection and CHttpFile. I like to do things the hard way, but I am not prepared to give out my buggy code that has cost me tens of hours of headaches so easily.

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw

IMN logo majestic logo threadwatch logo seochat tools logo