Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Community
Community
Notifications
close
  • Forums
  • Knowledge Center
  • Events & Webinars
  • Ideas
  • Blogs
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register
Sustainability
Sustainability

Join our "Ask Me About" community webinar on May 20th at 9 AM CET and 5 PM CET to explore cybersecurity and monitoring for Data Center and edge IT. Learn about market trends, cutting-edge technologies, and best practices from industry experts.
Register and secure your Critical IT infrastructure

ComX510 data Export via HTTP or HTTPS

Gateways and Energy Servers

Schneider Electric support forum to share knowledge about product selection, installation and troubleshooting for EcoStruxure Panel Server, PowerTag, Com'X, Link150…

cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Home
  • Schneider Electric Community
  • EcoStruxure Power & Grid
  • Gateways and Energy Servers
  • ComX510 data Export via HTTP or HTTPS
Options
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
Invite a Co-worker
Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel
Invitation Sent
Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
Top Experts
User Count
Romain_Polette
Spock Romain_Polette Spock
98
Randi_Dolan
Commander Randi_Dolan Commander
46
Guillaume_Evrard
Commander Guillaume_Evrard Commander
43
Thierry_Baudard
Commander Thierry_Baudard Commander
30
View All

Invite a Colleague

Found this content useful? Share it with a Colleague!

Invite a Colleague Invite
Solved Go to Solution
Back to Gateways and Energy Servers
Solved
Sushant_Belote
Lt. Commander | EcoXpert Master Sushant_Belote Lt. Commander | EcoXpert Master
Lt. Commander | EcoXpert Master

Posted: ‎2019-01-12 02:43 AM

3 Likes
1
966
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2019-01-12 02:43 AM

ComX510 data Export via HTTP or HTTPS

Hello Experts,

 

I am trying to export log data from ComX 510 to EMS server automatically.

I have successfully tested with FTP.

 

May i know how can i use HTTP & HTTPS methods for data export, as client restrict us to use FTP method.

 

Thanks in Advance.

 

 

 

Reply
  • All forum topics
  • Previous Topic
  • Next Topic

Accepted Solutions
Randi_Dolan
Commander Randi_Dolan Commander
Commander

Posted: ‎2019-01-12 05:54 PM . Last Modified: ‎2019-01-12 05:57 PM

3 Likes
0
963
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2019-01-12 05:54 PM

Hello,

 

To export data log file from the Com'X via HTTP or HTTPs, you will have to setup a web server and configure it to receive files from the Com'X.  Typically this is done with a script written in cgi or perl.

 

Here is a document on how to do this on the EGX300.  The Com'X works the same way.  Although, the fieldname is different.

 

EGX 300 - Logged Data Export over HTTP
======================================
​
​
Rationale
---------
Provide export of EGX300 logged data over HTTP.  This allows EGX's
inside firewalled and/or NAT'ed (Network Address Translated) networks
to export their logged data to external servers without port-forwarding
or other complications.
​
​
Background
----------
EGX 300 supports exporting logged data over Email (SMTP) and FTP.
This project adds the capability to "push" logged data over an HTTP
POST message. By doing so, common HTTP servers can aggregate logged
data from one or many EGX's.
​
​
Approach
--------
Provide export of EGX300 logged data over HTTP 'POST' method. Any
WWW server that supports POST messages and installing one's own CGI
handlers is sufficient. Our testing used Apache 1.3.34 (www.apache.org)
running on FreeBSD (www.freebsd.org). The same scripts will work
on a variety of WWW servers and operating systems. (Linux, OpenBSD,
Solaris, etc.)
​
The EGX will post a message specifying the filename of where to
deposit the POST data. By default this is 'datafile1', but this can
be customized in the EGX web interface. This would be useful in the
case where you already have a POST handler that uses a different
field name for this purpose.
​
​
Sample Upload handler - Python
------------------------------
The following is the full text of an EGX-compatible Python script 
that accepts HTTP uploads from EGX's. Install it into the directory
on your chosen web server where CGI scripts reside. (this varies by
hosting provider)
​
#! /usr/bin/env python
#
# based on http://webpython.codepoint.net/cgi_tutorial
#
import cgi, os
# cgitb module gives specific tracebacks when there is a problem,
#   rather than just a generic failure message.
import cgitb
cgitb.enable()
try: # Windows needs stdio set for binary mode.
    import msvcrt
    msvcrt.setmode (0, os.O_BINARY) # stdin  = 0
    msvcrt.setmode (1, os.O_BINARY) # stdout = 1
except ImportError:
    pass
form = cgi.FieldStorage()
# Generator to buffer file chunks
def fbuffer(f, chunk_size=10000):
   while True:
      chunk = f.read(chunk_size)
      if not chunk: break
      yield chunk
# A nested FieldStorage instance holds the file
fileitem = form['datafile1']
# Test if the file was uploaded
if fileitem.filename:
   # strip leading path from file name to avoid directory traversal attacks
   fn = os.path.basename(fileitem.filename)
   # Customize this directory to match your WWW server
   outfil = open('/usr/local/www/data/uploads/' + fn, 'wb', 10000)
   # Read the file in chunks
   for chunk in fbuffer(fileitem.file):
      outfil.write(chunk)
   outfil.close()
   message = 'The file "' + fn + '" was uploaded successfully\n'
else:
   message = 'No file was uploaded'
print """\
Content-Type: text/html\n
<html><body>
<p>%s</p>
</body></html>
""" % (message,)
​
​
Sample Upload handler - PERL
----------------------------
The following is the full text of an EGX-compatible PERL script to
accept HTTP file uploads.
​
#!/usr/bin/perl -wT
use strict;
use CGI;
# set maximum allowable size to 5MB
$CGI::POST_MAX = 1024 * 5000;
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $upload_dir = "/usr/local/www/data/uploads";
my $query = new CGI;
my $filename = $query->param('datafile1');
if ( !$filename )
{
  print $query->header ( );
  print "There was a problem uploading your file; try a smaller file.";
  exit;
}
my ( $name, $path, $extension ) = fileparse ( $filename, '\..*' );
$filename = $name . $extension;
$filename =~ tr/ /_/;
$filename =~ s/[^$safe_filename_characters]//g;
if ( $filename =~ /^([$safe_filename_characters]+)$/ )
{
  $filename = $1;
}
else
{
  die "Filename contains invalid characters";
}
open ( UPLOADFILE, ">", "$upload_dir/$filename" ) or die "$!";
binmode(UPLOADFILE);
my $upload_filehandle = $query->upload("datafile1");
while ( <$upload_filehandle> )
{
  print UPLOADFILE;
}
close UPLOADFILE;
print $query->header ( );
print <<END_HTML;
<html>
<body>
<p>The file $filename was uploaded successfully</p>
</body>
</html>
END_HTML
​
​
Microsoft Internet Information Services (IIS)
---------------------------------------------
IIS can most naturally use Active Server Pages (ASP) or ASP.NET
to upload files. Alternately, IIS can be configured to support CGI.
Unfortunately, IIS does not support CGI as installed "out of the box".
Then one may use PERL/Python/etc. CGI scripts as above.
​
​
Sample Upload handler - Microsoft Internet Information Services (IIS) w/ ASP.NET
--------------------------------------------------------------------------------
​
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
​
namespace EnergyDataReceiver
{
    public partial class filepost : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            String TempFileName;
            HttpFileCollection myFileCollection = Request.Files;
​
            for (int Loop1 = 0; Loop1 < myFileCollection.Count; Loop1++)
            {
                string fname = myFileCollection[Loop1].FileName;
                // Create a new file name.
                TempFileName = "C:\\TempFiles\\File_" + Loop1.ToString() + "_" + Path.GetFileName(fname);
                // Save the file.
                myFileCollection[Loop1].SaveAs(TempFileName);
            }
        }
    }
}
​
​
References
----------
1. RFC 1867 "Form-based File Upload in HTML",
    http://www.ietf.org/rfc/rfc1867.txt
2. File Upload with ASP.NET,
    http://www.codeproject.com/KB/aspnet/fileupload.aspx
3. Uploading a file to IIS using a browser,
    http://support.microsoft.com/default.aspx/kb/189651
4. Google Search of "IIS cgi" yields quite a few pointers and tutorials:
    http://www.google.com/search?q=IIS+cgi

 

Best regards,

Randi

 

See Answer In Context

Reply
Reply 1
Randi_Dolan
Commander Randi_Dolan Commander
Commander

Posted: ‎2019-01-12 05:54 PM . Last Modified: ‎2019-01-12 05:57 PM

3 Likes
0
964
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2019-01-12 05:54 PM

Hello,

 

To export data log file from the Com'X via HTTP or HTTPs, you will have to setup a web server and configure it to receive files from the Com'X.  Typically this is done with a script written in cgi or perl.

 

Here is a document on how to do this on the EGX300.  The Com'X works the same way.  Although, the fieldname is different.

 

EGX 300 - Logged Data Export over HTTP
======================================
​
​
Rationale
---------
Provide export of EGX300 logged data over HTTP.  This allows EGX's
inside firewalled and/or NAT'ed (Network Address Translated) networks
to export their logged data to external servers without port-forwarding
or other complications.
​
​
Background
----------
EGX 300 supports exporting logged data over Email (SMTP) and FTP.
This project adds the capability to "push" logged data over an HTTP
POST message. By doing so, common HTTP servers can aggregate logged
data from one or many EGX's.
​
​
Approach
--------
Provide export of EGX300 logged data over HTTP 'POST' method. Any
WWW server that supports POST messages and installing one's own CGI
handlers is sufficient. Our testing used Apache 1.3.34 (www.apache.org)
running on FreeBSD (www.freebsd.org). The same scripts will work
on a variety of WWW servers and operating systems. (Linux, OpenBSD,
Solaris, etc.)
​
The EGX will post a message specifying the filename of where to
deposit the POST data. By default this is 'datafile1', but this can
be customized in the EGX web interface. This would be useful in the
case where you already have a POST handler that uses a different
field name for this purpose.
​
​
Sample Upload handler - Python
------------------------------
The following is the full text of an EGX-compatible Python script 
that accepts HTTP uploads from EGX's. Install it into the directory
on your chosen web server where CGI scripts reside. (this varies by
hosting provider)
​
#! /usr/bin/env python
#
# based on http://webpython.codepoint.net/cgi_tutorial
#
import cgi, os
# cgitb module gives specific tracebacks when there is a problem,
#   rather than just a generic failure message.
import cgitb
cgitb.enable()
try: # Windows needs stdio set for binary mode.
    import msvcrt
    msvcrt.setmode (0, os.O_BINARY) # stdin  = 0
    msvcrt.setmode (1, os.O_BINARY) # stdout = 1
except ImportError:
    pass
form = cgi.FieldStorage()
# Generator to buffer file chunks
def fbuffer(f, chunk_size=10000):
   while True:
      chunk = f.read(chunk_size)
      if not chunk: break
      yield chunk
# A nested FieldStorage instance holds the file
fileitem = form['datafile1']
# Test if the file was uploaded
if fileitem.filename:
   # strip leading path from file name to avoid directory traversal attacks
   fn = os.path.basename(fileitem.filename)
   # Customize this directory to match your WWW server
   outfil = open('/usr/local/www/data/uploads/' + fn, 'wb', 10000)
   # Read the file in chunks
   for chunk in fbuffer(fileitem.file):
      outfil.write(chunk)
   outfil.close()
   message = 'The file "' + fn + '" was uploaded successfully\n'
else:
   message = 'No file was uploaded'
print """\
Content-Type: text/html\n
<html><body>
<p>%s</p>
</body></html>
""" % (message,)
​
​
Sample Upload handler - PERL
----------------------------
The following is the full text of an EGX-compatible PERL script to
accept HTTP file uploads.
​
#!/usr/bin/perl -wT
use strict;
use CGI;
# set maximum allowable size to 5MB
$CGI::POST_MAX = 1024 * 5000;
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $upload_dir = "/usr/local/www/data/uploads";
my $query = new CGI;
my $filename = $query->param('datafile1');
if ( !$filename )
{
  print $query->header ( );
  print "There was a problem uploading your file; try a smaller file.";
  exit;
}
my ( $name, $path, $extension ) = fileparse ( $filename, '\..*' );
$filename = $name . $extension;
$filename =~ tr/ /_/;
$filename =~ s/[^$safe_filename_characters]//g;
if ( $filename =~ /^([$safe_filename_characters]+)$/ )
{
  $filename = $1;
}
else
{
  die "Filename contains invalid characters";
}
open ( UPLOADFILE, ">", "$upload_dir/$filename" ) or die "$!";
binmode(UPLOADFILE);
my $upload_filehandle = $query->upload("datafile1");
while ( <$upload_filehandle> )
{
  print UPLOADFILE;
}
close UPLOADFILE;
print $query->header ( );
print <<END_HTML;
<html>
<body>
<p>The file $filename was uploaded successfully</p>
</body>
</html>
END_HTML
​
​
Microsoft Internet Information Services (IIS)
---------------------------------------------
IIS can most naturally use Active Server Pages (ASP) or ASP.NET
to upload files. Alternately, IIS can be configured to support CGI.
Unfortunately, IIS does not support CGI as installed "out of the box".
Then one may use PERL/Python/etc. CGI scripts as above.
​
​
Sample Upload handler - Microsoft Internet Information Services (IIS) w/ ASP.NET
--------------------------------------------------------------------------------
​
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
​
namespace EnergyDataReceiver
{
    public partial class filepost : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            String TempFileName;
            HttpFileCollection myFileCollection = Request.Files;
​
            for (int Loop1 = 0; Loop1 < myFileCollection.Count; Loop1++)
            {
                string fname = myFileCollection[Loop1].FileName;
                // Create a new file name.
                TempFileName = "C:\\TempFiles\\File_" + Loop1.ToString() + "_" + Path.GetFileName(fname);
                // Save the file.
                myFileCollection[Loop1].SaveAs(TempFileName);
            }
        }
    }
}
​
​
References
----------
1. RFC 1867 "Form-based File Upload in HTML",
    http://www.ietf.org/rfc/rfc1867.txt
2. File Upload with ASP.NET,
    http://www.codeproject.com/KB/aspnet/fileupload.aspx
3. Uploading a file to IIS using a browser,
    http://support.microsoft.com/default.aspx/kb/189651
4. Google Search of "IIS cgi" yields quite a few pointers and tutorials:
    http://www.google.com/search?q=IIS+cgi

 

Best regards,

Randi

 
Reply
Preview Exit Preview

never-displayed

You must be signed in to add attachments

never-displayed

 
To The Top!

Forums

  • APC UPS Data Center Backup Solutions
  • EcoStruxure IT
  • EcoStruxure Geo SCADA Expert
  • Metering & Power Quality
  • Schneider Electric Wiser

Knowledge Center

Events & webinars

Ideas

Blogs

Get Started

  • Ask the Community
  • Community Guidelines
  • Community User Guide
  • How-To & Best Practice
  • Experts Leaderboard
  • Contact Support
Brand-Logo
Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Forum-Icon

Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.

Register today for FREE

Register Now

Already have an account? Login

Terms & Conditions Privacy Notice Change your Cookie Settings © 2025 Schneider Electric

This is a heading

With achievable small steps, users progress and continually feel satisfaction in task accomplishment.

Usetiful Onboarding Checklist remembers the progress of every user, allowing them to take bite-sized journeys and continue where they left.

of