LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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-28-2008, 03:08 PM   #1
chackercon
Member
 
Registered: Jan 2008
Location: Oklahoma
Distribution: Slackware, QNX, Centos 5.2, Dream Linux, BackTrack, Fedora
Posts: 53

Rep: Reputation: 18
Web site command/terminal script


I have 4 QNX machines on my shop floor that are used to run a machine. This machine collects the data to one file. The Employees use windows xp sp2 to access the machine via FTP script. There a about 10 users and the same amount of PC in this solution.

I have be asked to removed the QNX machines from the corporate network. So I created a Vlan that only has access to a few machines on the corporate network and moved the QNX machines to that new location.

On the corporate network I have a Slackware Linux server running apache that communicates to the 17 other QNX machines and then relays that information back to the Windows machines. This has worked great for me so far.

I would like to use php or pearl to execute a script on the web server that would connect to the QNX server via FTP get a file and then automatically run a script on the xp machine that would ftp the file to the windows machine.

The problem that I have is I am not a programmer I would like to know if there is anyone that could help me accomplish this task. Any help or direction would be greatly appreciated.
 
Old 07-28-2008, 07:10 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Well, to avoid the issue of synchronizing scripts on eg webserver & XP, use one Perl prog on webserver to get file from QNX, then send to XP box(es).
Obviously you'll need ftp server for incoming on XP boxes.


I don't have an example of ftp get, but here's the docs (incs examples)
http://search.cpan.org/~gbarr/libnet-1.22/Net/FTP.pm

Here's the Perl FTP send code:
Code:
#******************************************************************************
#
# Function      : ftp_send_file
#
# Description   : Ftp send file to somewhere
#
# Params        : $_[0]    file to send (inc path)
#
# Returns       : none
#
#******************************************************************************
sub ftp_send_file
{
    my (
        $src_file,    # filename inc path
        $ftp          # net::ftp object
        );

    # Assign input param
    $src_file = $_[0]

    # Txmit file
    $ftp = Net::FTP->new($cfg::params{'FTP_HOST'}) or
                    exit_with_error(
                        "Can't connect to $cfg::params{'FTP_HOST'}: $@\n");
    $ftp->login($cfg::params{'FTP_USER'}, $cfg::params{'FTP_PASSWD'}) or
                    exit_with_error(
                        "Can't login to $cfg::params{'FTP_HOST'}: ".
                                                            $ftp->message);
    $ftp->put($cfg::params{'OUT_DIR'}.$src_file) or
                exit_with_error("Can't FTP PUT file ".
                                "$cfg::params{'OUT_DIR'}.$src_file: ".
                                                            $ftp->message);
    $ftp->quit;
}
Create your own exit_with_error() sub to do whatever you want. Mine usually writes to a logfile and sends an email (for important stuff).

Top 2 lines in Perl progs:

#!/usr/bin/perl -w

use strict; # Enforce declarations

As you can see from the docs, you'll also need
use Net::FTP; # import FTP api cmds

Here's the full Perl docs (again, incs tutorials & examples):
http://perldoc.perl.org/

BTW, this sort of 'glue' job is exactly what Perl was designed for originally.
 
Old 07-28-2008, 08:02 PM   #3
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Might be easier to have the XP machine request the information from the web server. The web server then accesses the QNX machine to get the information, and forwards it to the XP machine like any other web download.

Eliminates the requirement to deploy an FTP server on the XP machine. In fact, eliminates any requirement to do anything to the XP machine, other than write the VBA script to have IE access the web server.
 
Old 07-29-2008, 08:08 AM   #4
chackercon
Member
 
Registered: Jan 2008
Location: Oklahoma
Distribution: Slackware, QNX, Centos 5.2, Dream Linux, BackTrack, Fedora
Posts: 53

Original Poster
Rep: Reputation: 18
Guys these are great ways of getting this accomplished. And two great tools to add to my toolbox. I like the pearl script because it looks clean and easy to use. However I like the VBA solution because it does not require me to open FTP services on the XP machines which would not go over well with our network security people.
So if I can I would like to use the pearl script to get the file via FTP from qnx. I would then want to use vba to allow the user to download the file from the web server like a normal download. Is this possible?
Do you have any examples of the code that I would need to write or a location to find the code?

Thank you guys for all your help.
Mike
 
Old 07-29-2008, 11:52 AM   #5
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Is it possible? Sure its possible.

But no one is going to hand you a complete solution; every installation is different.
 
Old 07-29-2008, 02:36 PM   #6
chackercon
Member
 
Registered: Jan 2008
Location: Oklahoma
Distribution: Slackware, QNX, Centos 5.2, Dream Linux, BackTrack, Fedora
Posts: 53

Original Poster
Rep: Reputation: 18
Jim
I am not looking for a complete solution. I want to do this myself I am just not a programmer and I need to make sure that my expectations are set correctly before I start working on this project. With that said I am enjoying reading about the information that has been posted and learning new things.
I am having a few problems with the perl script that gets the file from the QNX server. I will continue to work on it and when I feel like I have hit a wall I will come back and post again.
Thank you for all the help
Mike
 
Old 07-29-2008, 07:34 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
As i said, if you go that route, you have the issue of syncing the 2 scripts ie ideally you'd want the VBA script to only run if the file is avail from the server. What is it going to do to warn the user if it finds nothing?
Don't get me wrong you can still do that.
In fact if the middle box is a webserver you could write a VBA script to call a cgi script on the webserver, which is the ftp get from the QNX box.

Come back if you have probs with the Perl. As you said, its clean/short. Probs with ftp usually resolve to permissions/firewalls.
 
Old 07-30-2008, 01:35 PM   #8
resetreset
Senior Member
 
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Rep: Reputation: 62
It's really interesting that someones using QNX - I almost forgot about it, I used a looooong time ago. How is it doing these days?
(btw can you check whether wget or curl will help you? whyd you have to use perl?)
 
Old 08-01-2008, 06:08 PM   #9
chackercon
Member
 
Registered: Jan 2008
Location: Oklahoma
Distribution: Slackware, QNX, Centos 5.2, Dream Linux, BackTrack, Fedora
Posts: 53

Original Poster
Rep: Reputation: 18
Well we are still using QNX 4.2 so I am not sure about the new stuff. I installed and was running like 6.2 for a bit and it seemed to be better, howeve there is still not a lot of driver support. I decided to use NFS to mount the directory and just make the web page do a regular download thank you all for all the help I am still going to work through a few of the solutions that where suggested in the lab so that I can build my skills.

Thanks for all the help.
Mike
 
  


Reply



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
Looking for web dev tool that can import an entire web site drokmed Linux - General 2 06-02-2008 07:30 PM
Script or Terminal command to switch audio output? jjsonp Linux - Software 0 01-26-2008 01:10 PM
How do I use sftp to upload my web site? (no sftp tar command) johnMG Linux - Networking 6 06-21-2005 09:14 PM
prevent irc script accessing web site dtra Linux - Networking 3 06-09-2005 06:10 AM
Any good Web site control panel script? gogo Linux - Software 3 06-22-2002 08:14 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:12 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration