Sign in to follow this  
Followers 0
Roatandave

Terminal Module

25 posts in this topic

Hello Everyone,

I have a shell terminal written in PHP, It is all in one file and works on the Nano. Termconsole.php

I replaced the index file with it and rebooted and brought up a terminal instead of the dashboard

through the first page

What I do not know is how to make a module for it as I know nothing of programing.

Could someone please help with the module.html file

I found this file on the net and has some useful commands.

 

 

0

Share this post


Link to post
Share on other sites
3 hours ago, Roatandave said:

Hello Everyone,

I have a shell terminal written in PHP, It is all in one file and works on the Nano. Termconsole.php

I replaced the index file with it and rebooted and brought up a terminal instead of the dashboard

through the first page

What I do not know is how to make a module for it as I know nothing of programing.

Could someone please help with the module.html file

I found this file on the net and has some useful commands.

 

 

I’m also interested in being able to do something very similar to this. I found an app using a php file but would like to make it into a html file with the hope of being able to build a basic pineapple module. Any guidance very welcome.

edit - is it as simple as embedding the php into a html doc? like here

edit the edit - no, embedding didn’t seem to work at all :) I used @Foxtrot module maker and tried embedding the php into the html and I failed miserably lol

Edited by Just_a_User
0

Share this post


Link to post
Share on other sites

I'd love to try and point you in the right direction.. what failed when you tried making the module?

0

Share this post


Link to post
Share on other sites
On 12/02/2017 at 3:30 AM, Foxtrot said:

I'd love to try and point you in the right direction.. what failed when you tried making the module?

To start, thank you for even looking at this I know this is most likely a stupid question to you.

I found some code on github written in PHP. It that allows control of a Huawei-HiLink USB modem via web API not using serial.

https://github.com/BlackyPanther/Huawei-HiLink

If you look you see there is a index.php with a class.php. I very crudely tried to put the index.php into the module maker module.html and positioned the class.php both in the module root and api directory (wasn’t sure). All I was getting was text (from the index.php file) output. I'm so far out of my depth im surprised I got that much out of it without breaking more, but tried it on the off chance it would work.

Is it a case of having to understand the full php contents enough to rewrite it into proper module.html? if so I'm tapping out and it has to become a feature request for the official modem manager module.

either way cheers for your time.

Update - php5-cli

Read online that a development server can be run direct from php. I tried on the pineapple but so far I haven’t been able to get it to completely work.

To install

opkg install php5-cli 

and to run use the below changing port if required.

php -S 127.0.0.1:8080 

I can get it to run but to get those PHP files to run on the pineapple it was missing a couple of php5-mod files. One being simplexml and when I installed it I lost part of the pineapple dashboard, even after reboot and a shutdown. I think I'm at a dead end with this so I add it here in name of sharing information. Maybe someone else could find is useful

 

Edited by Just_a_User
update - php5-cli
0

Share this post


Link to post
Share on other sites

I tried that and failed also, I am tring now is to make a module with a single page web browser with a dedicated address and set the php to run in a little server and have the browser point to it. It is a small java app that I have to compile and then get that into the module. The one that looks promising is PHPTerm - small lightweight and looks to have good access to the command line. This will have to wait till I finish fixing the system crash I had this morning.

I will let all of you know.

0

Share this post


Link to post
Share on other sites

I think the first thing you need to understand is the architecture of a module.  You could watch the video that Seb and Darren put together a while back on building modules but I'll give a quick description here.

index.html - The homepage of your module.  It contains all of the code to display the features of your module to the user.  It also contains elements of AngularJS to bind controls to functions in your module.js file.

js/module.js - Includes an AngularJS controller with all necessary code to interface between index.html and module.php asynchronously.

api/module.php - Contains the server-side code that performs tasks when called by module.js.

In the case of building a web terminal it would be as simple as having a textarea in index.html with a javascript event that fires every time return is pressed.  When the event fires it would call a function within module.js that extracts the last line of text from the data within the textarea (this can be a variable within your scope that is simply bound to the textarea).  It then sends an AJAX request to module.php which takes the line, runs it through a function like shell_exec and returns the output to module.js.  When it's received, your function in module.js appends the returned data to the scoped variable that's bound to your textarea and it automatically gets updated in the user interface.

Of course it would take a bit more work than this to make everything look exactly like a shell, and for it to be secure, but the basic functionality really is simple.

1

Share this post


Link to post
Share on other sites

Well some success, I have ajax terminal written in python working on the nano.

Its not pretty but, its all local and has a login for the local user and looks to have full command access.

it looks good so far. now to start on the rest.

there is a starting point. If you try it - open the file qweb goto line 109 and remove email and xml entries. as they will not be needed anyway.

172 kb in size.

0

Share this post


Link to post
Share on other sites

Update: Mostly working, need to put in title and work on start and stop buttons.

Working on bugs in the configuration.

0

Share this post


Link to post
Share on other sites

Due to lack of interest this, this is closed. it works. go build your own.

0

Share this post


Link to post
Share on other sites

@Roatandave are you kidding? Lack of interest? Ive been waiting to see something actually get posted here besides just "How to make a module".  In a matter of 2 days you made this and not even a screen shot or a github link.  

Edited by b0N3z
0

Share this post


Link to post
Share on other sites

Sorry I did not think anyone was watching. I am not a programmer just an old user. I will put this on my github tomorrow. I need some sleep after 5 18 hour days trying to figure this out, I would like some help. Thank You. You Have made me want to continue.

0

Share this post


Link to post
Share on other sites

This is really not as hard as people think the dashboard is only a web page. You just have to make a link to the program behind  it.

0

Share this post


Link to post
Share on other sites

Yea get it on github and I will check it out and see what I can help you with

0

Share this post


Link to post
Share on other sites

Will do, btw not to be funny but 40 years ago my sister had a cat named bonz

0

Share this post


Link to post
Share on other sites

Sorry I didn't reply after saying I'd try and help sooner... @sud0nick nailed it. From what I can see from posts is that its a service running on its own port?

 

9 hours ago, Roatandave said:

Due to lack of interest this, this is closed. it works. go build your own.

That's not a very good attitude to have, especially considering you started the thread... sharing knowledge is greatly appreciated.

0

Share this post


Link to post
Share on other sites

I apologize to all for my comments above.It was just a lack of sleep and frustration. I thank all of you for your interest and for correcting me.

Yes, it starts its own port at localhost:8022 and broadcasts its own ajaxterm.html. The iframe in module.html is directed to this port and displays the terminal.

In the Ajaxterm_files directory is ajaxterm.py which starts the terminal.

The help that I need is  putting a start/stop button in the module.html to enable and disable the terminal.

Here is the link to my github.

Edit: After days of searching and trying many terminal apps, I chose this one for it's size and it works in the Nano

https://github.com/Roatandave/Nano-Terminal

Edited by Roatandave
2

Share this post


Link to post
Share on other sites
3 hours ago, Roatandave said:

I apologize to all for my comments above.It was just a lack of sleep and frustration. I thank all of you for your interest and for correcting me.

Yes, it starts its own port at localhost:8022 and broadcasts its own ajaxterm.html. The iframe in module.html is directed to this port and displays the terminal.

In the Ajaxterm_files directory is ajaxterm.py which starts the terminal.

The help that I need is  putting a start/stop button in the module.html to enable and disable the terminal.

Here is the link to my github.

Edit: After days of searching and trying many terminal apps, I chose this one for it's size and it works in the Nano

https://github.com/Roatandave/Nano-Terminal

Update: I put it in rc.local and nothing. Firefox is giving me the unable to connect to server error. Trying again.

0

Share this post


Link to post
Share on other sites
20 minutes ago, Roatandave said:

Update: I put it in rc.local and nothing. Firefox is giving me the unable to connect to server error. Trying again.

Nmap show that it is not getting through the module.

 

0

Share this post


Link to post
Share on other sites

Sorry Foxtrot I forgot to say, I am not building a regular module. I am trying to get a terminal app to pass the command line to the dashboard without having to go through ssh.

Just to go in and make quick changes.

2

Share this post


Link to post
Share on other sites

Hi Roatandave,

I just wanted to chime in on this module and give some guidance.

First of all, I would suggest taking a look at the Let's Code we did about a year ago. It will provide you with enough information to properly format and develop your module. Taking a look at the Github link you provided, I noticed that the module.html is formatted incorrectly, and there is no module.info file. There are also duplicate and .pyc files in your Ajaxterm_files folder, which you may want to clean up.

I would also like to talk about security a bit. While ajaxterm does seem to authenticate the user, there is no encryption or much regard given to security. This would somehow need to be resolved before we would be able to publish this module in our repository. I am sure this is possible, but it may actually be easier to re-write the terminal emulator from the ground up, and letting it interface directly with the WiFi Pineapple's module API.

2

Share this post


Link to post
Share on other sites

Thank you for looking, I found this program on the net and is only a starting point, an idea and yes it is a mess right now. I am not a programmer or a developer, just an old fart with some time to kill and enjoying the mental exercise.

1

Share this post


Link to post
Share on other sites
6 hours ago, Roatandave said:

Thank you for looking, I found this program on the net and is only a starting point, an idea and yes it is a mess right now. I am not a programmer or a developer, just an old fart with some time to kill and enjoying the mental exercise.

I suggest you re-read my earlier post.  I'll quote it for convenience.  Pay particular attention to the paragraph that details how you can build this module without using a Python script you've found online.

On 2/12/2017 at 1:21 PM, sud0nick said:

I think the first thing you need to understand is the architecture of a module.  You could watch the video that Seb and Darren put together a while back on building modules but I'll give a quick description here.

index.html - The homepage of your module.  It contains all of the code to display the features of your module to the user.  It also contains elements of AngularJS to bind controls to functions in your module.js file.

js/module.js - Includes an AngularJS controller with all necessary code to interface between index.html and module.php asynchronously.

api/module.php - Contains the server-side code that performs tasks when called by module.js.

In the case of building a web terminal it would be as simple as having a textarea in index.html with a javascript event that fires every time return is pressed.  When the event fires it would call a function within module.js that extracts the last line of text from the data within the textarea (this can be a variable within your scope that is simply bound to the textarea).  It then sends an AJAX request to module.php which takes the line, runs it through a function like shell_exec and returns the output to module.js.  When it's received, your function in module.js appends the returned data to the scoped variable that's bound to your textarea and it automatically gets updated in the user interface.

Of course it would take a bit more work than this to make everything look exactly like a shell, and for it to be secure, but the basic functionality really is simple.

 

0

Share this post


Link to post
Share on other sites

Thank for the redirection I will start again.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.