top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Telnet to remote system and format output via web page

+1 vote
808 views

I would like to create a web app using flask or cgi library (python) along with telnetlib to telnet to specific servers and execute commands and retrieve the output. The output will then be formatted and outputted to a webpage .

Is this the best way of getting info from a remote system to be output to a web page? Is flask over kill for project like this ?

posted Sep 11, 2013 by Majula Joshi

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
Is security an issue ? How sensitive is the information you are querying? Must it be Telnet ?

1 Answer

+1 vote

I never used Flask, but most of python web framework provide an easy/quick way of setting up a web application server. So I'd say Flask is just fine.

What concerns me is the telnet protocol you plan to use for remote execution. Do you have any other options ? are you trying to execute on a remote unix like system ?

Anyway if you must stick with telnet, I don't see anything wrong in your plan, Flask + telnetlib should do the trick.

answer Sep 11, 2013 by Sumit Pokharna
Similar Questions
+1 vote

I want to set up a very simple website, and I need to know if it is necessary to use a web framework (e.g. Django) to do basic interactive operations such as receiving input from the user, looking up a database and returning some data to the user.

I know that this is exactly the purpose of web frameworks, and that they work fine. However, I read somewhere that for small projects such operations can be managed without a web framework, just by using Python with mod_python or with the CGI module. Is this correct?

Any suggestions?

+2 votes

I am developing a web application using flask, Werkzeug and jinja2. I am very much confused with these terms and wanted to know the meaning of the terms and how they are interrelated to the CGI environment variables. What is global variable g and how it is related to the application context and request context.

Also since I don't have much knowledge of developing web apps( I am doing it for first time) any another language also so there is another request if someone could give a reference or make me understand that how the requests are handled, i mean what happens when a request arrives to the web application.
Also if i am not using any openID providers for logging in the user into my website, how can i make the password secure. Should i use any framework for that?

0 votes

i want to sent a response for my form submit from server to client, that means python flask to javascript. My javascript code is given follows

document.addEventListener('DOMContentLoaded', function() {

chrome.tabs.getSelected(null, function(tab) {
  d = document;
  var f = d.createElement('form');
  f.action = 'http://127.0.0.1:5000/Get%20Form/';
  f.method = 'post';
  var i = d.createElement('input');
  i.type = 'hidden';
  i.name = 'url';
  i.value = tab.url;
  f.appendChild(i);
  d.body.appendChild(f);
  f.submit();   
});
$(".button").click(function(){
    request = new XMLHttpRequest();
    request.open("POST","http://127.0.0.1:5000/PutValue/",true);
    request.send();
    request.addEventListener("readystatechange", processRequest,false);
    function processRequest(e)
    {
    if(request.readyState==4 && request.status == 200)
    {
    var response = JSON.parse(request.responseText);
    a=response.result
    alert(a);
    }
    }
});
},false);

And my Python server code is follows

from flask import Flask, flash, redirect, url_for, request, render_template,jsonify
import json
import UrlTest
import trainingSet as ts

app = Flask(__name__)
user=""
s=0

@app.route('/Get Form/',methods = ['POST'])
def GetForm():
request.method == 'POST'
url=request.form['url']
UrlTest.process_test_url(url,'test_features.csv')
s=ts.main_caller('url_features.csv','test_features.csv')
print s
return str(s)

@app.route('/PutValue/',methods = ['POST'])
def PutValue():
request.method == 'POST'
print s
return jsonify(result=s)


if (__name__ == '__main__'):
app.run(debug=True,host='0.0.0.0', use_reloader=False)

I want to send the value of s to the javascript client. please help me to send this the value of s.
and if u can suggest the complete code in javascipt and python

+1 vote

I have a python script (web service with query postgresql/postgis). Up to now, i did several test on my local laptop station (windows).

Now i want to execute this python script on our remote server (Web server : Apache;OS : Linux).

How to write a CGI template please? Can someone help me?

+3 votes

I am trying to upload files through html page in our Windows based server but I don't know how to take the files on remote server & save files there

...