LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-05-2005, 12:57 PM   #1
mrobertson
Member
 
Registered: May 2005
Posts: 275

Rep: Reputation: 30
Sending a file to a web server via ftp


I have written a vb6 app that generates a simple text file. I want to be able to send that text file to a web server. More specifically, this web server is one of an axis network camera. The camera has a linux os built in and I plan to rean the text file from the camera. The problem is that the camera will not accept files with the .txt extension. So overall, what I need to do is change the name of the file from camdata.txt to just camdata (no extension and then send it to the camera via ftp or another efficient means. The camera does not support sockets so winsock would be out of the question. Could anyone help me with this?
 
Old 07-05-2005, 01:09 PM   #2
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,614

Rep: Reputation: 136Reputation: 136
I think you could use a batch ftp file with the windows ftp built-in command,
so ftp login, upload, close are automatic

try ftp /? or help ftp at the cmd prompt, you look for ftp -f file or similar
 
Old 07-05-2005, 01:11 PM   #3
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
What would be the syntax to execute these things in vb6? I am not sure I understand.
 
Old 07-05-2005, 01:17 PM   #4
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,614

Rep: Reputation: 136Reputation: 136
I dont know vb6 but that could be :
Code:
system("ftp -s:C:\ftp.cmd");
Where C:\ftp.cmd contains :
Code:
open server
yourusername
yourpassword
cd /path/to/dir/where/upload/the/file
put camdata
Assuming camdata is in the current directory
 
Old 07-05-2005, 01:21 PM   #5
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
So I just need to type:


Code:
system("ftp -s:C:\ftp.cmd");
on the command line and that would be all?
I dont see how it is going to know what file to get. Could you explain in a little more detail?
 
Old 07-05-2005, 01:44 PM   #6
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,614

Rep: Reputation: 136Reputation: 136
Quote:
I dont see how it is going to know what file to get.
So you want to upload or download the file ?
 
Old 07-05-2005, 01:49 PM   #7
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
I want to upload the file. If you could let me know exactly what I need to do, that would be great. I really did not understand the last post I have a file that is stored in my c:\ drive and I want to upload it. Thanks.
 
Old 07-05-2005, 02:04 PM   #8
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,614

Rep: Reputation: 136Reputation: 136
so create a file with notepad with the content I posted above
(ftp.cmd) of course replace server with the ftp server address,
and replace yourusername and yourpassword as well
(I think it is simple to understand what to replace, very simple
syntax)

then save it in c:\ftp.cmd
now open cmd.exe and type :
Code:
ftp -s:c:\ftp.cmd
 
Old 07-06-2005, 07:38 AM   #9
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
I tried to do your suggestion. I made a file that looks as follows:

Code:
ftp://pl7cam3
root
pass
cd c:\Camera Data\camdata.txt
put camdata.txt
When I tried to execute the code, I got the following:

U:\> ftp -s:c:\ftp.cmd
ftp> ftp://pl7cam3
Invalid Command
ftp>root
Invalid Command
ftp>pass
Invalid Command
ftp> cd c:\Camera Data\camdata.txt
Not Connected
ftp> put camdata.txt
Not Connected


There are a couple of questions that I have however. My camdata.txt is stored locally on my pc. This program will have to run on a separate pc eventually meaning that it will have to go on the network and get the file from my pc. So my cd c:\......... may not be right. Also should the ftp.cmd be saved to the c:\ drive on my pc or to the camera that it will run on(a separate pc).....therefore I would be executing these commands from a telnet session. That may be confusing but I guess the first thing would be to atleast get the code working.......I was not able to connect to a ftp session. If from the u:/> prompt I typed ftp pl7cam3...I was able to get connected to a session.
 
Old 07-06-2005, 08:51 AM   #10
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
I have made some progress. I changed my code to the following and got a connection and successful commands:

Code:
open pl7cam3
root
pass
cd etc
put camdata.txt
Now I am getting a file not found message. camdata.text is located locally in the c:\Camera Data\camdata.text location. How would I be able to get it from there and put it in the etc directory of pl7cam3?
 
Old 07-06-2005, 09:04 AM   #11
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
Ok...I have been able to get the file to be transfered by using:

Code:
open pl7cam3
root
pass
cd etc
get camdata.txt camdata
put camdata
No I have one last question. The file is now on the camera.....I have a script on the camera that will read the file which is:

Code:
#!/bin/sh
while sleep1
         do
                 cat camdata
done
I need to add code to make sure that file is ftp 'd to the camera every second and then read and printed out. Do I have to save the ftp.cmd to the camera and thenuse the following code:

Code:
#!/bin/sh
while sleep1
         do
                 ftp -s://pl7cam3/etc/ftp.cmd
                 cat camdata
done
Or what would be the way to do this?

Last edited by mrobertson; 07-06-2005 at 09:08 AM.
 
Old 07-06-2005, 09:12 AM   #12
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
Or is there a way that I can execute :


ftp -s:c:\ftp.cmd

from vb6 every second based on a timer?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ftp(through web site access to ftp server) kelper Linux - Software 3 01-11-2006 07:03 PM
Best Distro for web/file/ftp server jess1975 Linux - Networking 12 04-01-2005 05:16 AM
Good distro for network/file/print/ftp/web server... AudioMechanic Linux - General 3 03-09-2005 10:12 AM
Sending WAN IP address to FTP server sloik2000 Linux - Networking 2 02-08-2005 02:59 PM
Setup a linux server, DNS, WEB, FTP, and Mail Server Help watermelon_lee Linux - Networking 1 08-26-2003 03:09 AM


All times are GMT -5. The time now is 04:25 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration