LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to run bash script from link on webpage? (https://www.linuxquestions.org/questions/linux-general-1/how-to-run-bash-script-from-link-on-webpage-4175450131/)

inkscape 02-14-2013 08:38 AM

How to run bash script from link on webpage?
 
Hello
I'd like run bash srcript (click on webpage link).
So I create new network.protocol-handler.app.bash (value /usr/bin/terminal) in firefox (about:config).
Click on link to script (bash:///home/user/moj/echo.bash)
And I have firefox error
Code:

Firefox doesn't know how to open this address, because the protocol (bash) isn't associated with any program
Maybe I need register new url scheme in my xfce?

TB0ne 02-14-2013 09:16 AM

Quote:

Originally Posted by inkscape (Post 4891534)
Hello
I'd like run bash srcript (click on webpage link).
So I create new network.protocol-handler.app.bash (value /usr/bin/terminal) in firefox (about:config).
Click on link to script (bash:///home/user/moj/echo.bash)
And I have firefox error
Code:

Firefox doesn't know how to open this address, because the protocol (bash) isn't associated with any program
Maybe I need register new url scheme in my xfce?

No, you need to read up on how to write web pages to execute code. Scripts/programs are typically in the cgi-bin directory, or can be called through PHP or javascript functions. Your window manager has nothing to do with it.

Just from putting "how to run a script from a webpage" into Google, it pulls up this as the very first hit:
http://www.cyberciti.biz/faq/run-she...from-web-page/

inkscape 02-14-2013 09:36 AM

I don't want php/java. I rather think about something like this:
http://askubuntu.com/questions/16155...a-shell-script

unSpawn 02-14-2013 10:25 AM

Web browsers recognize and handle certain MIME types themselves (text/html, image/png, etc, etc.). Those that aren't recognized internally are often handled by plugins (application/pdf, video/mp4, etc, etc.). If no "helper" applications are found you'll be asked to point to one. So, if you mean you want to execute an application based on a protocol (say "magnet://") or a MIME type (application/x-shellscript, text/x-java), then that will work. Maybe you should be specific about what you want to achieve and give an example.

TB0ne 02-14-2013 10:49 AM

Quote:

Originally Posted by inkscape (Post 4891568)
I don't want php/java. I rather think about something like this:
http://askubuntu.com/questions/16155...a-shell-script

Ok...did you read the link I posted in my first reply?? It has an example of how to do it, along with a bash script.

inkscape 02-14-2013 12:53 PM

@TB0ne I read. I want start bash script by click link on local web page.
I haven't running web server
Code:

ls -la /etc/rc.d/rc.httpd
-rw-r--r-- 1 root root 1061 sie 23 18:07 /etc/rc.d/rc.httpd

@unSpawn I have some html pages created with asciidoc, and I want edit it with text editor.
On each of them will put a link that will open an external editor and I can easily edit sources files (.txt).

unSpawn 02-14-2013 02:01 PM

Then why not just use a File manager if the files are local, or a Graphical SFTP or FTPS client if they are remote, browse, double click item to open with the editor and be done with it?

inkscape 02-14-2013 02:08 PM

because I want use firefox and I do not want to get around the problem

TB0ne 02-14-2013 02:33 PM

Quote:

Originally Posted by inkscape (Post 4891708)
@TB0ne I read. I want start bash script by click link on local web page.
I haven't running web server
Code:

ls -la /etc/rc.d/rc.httpd
-rw-r--r-- 1 root root 1061 sie 23 18:07 /etc/rc.d/rc.httpd


Then your question makes no sense at all. If you don't have a web server, how do you think you're going to serve up web pages???. If you're just clicking File->Open on a local file, open it with a text-editor, which is what it was DESIGNED TO DO.

Otherwise, the link I gave you explicitly tells you how to make a bash script work through a web page, and has an example of how to do it. Doesn't get much simpler than that. So, if you did read/understand it, you have an answer.
Quote:

Originally Posted by inkscape
because I want use firefox and I do not want to get around the problem

No, you're not 'getting around' a problem by using the right program for the right job...you're doing what makes the most sense, and using the correct tool for the job. Using a web browser to open a shell script to open a file is creating a LOT more work for yourself, and is going to CREATE problems, and make things harder to use.

chrism01 02-15-2013 12:43 AM

This
Quote:

Then your question makes no sense at all. If you don't have a web server, how do you think you're going to server up web pages???.
I'm so glad you said that; I thought for a minute it was just me ;)

inkscape 02-15-2013 09:43 AM

I edit firefox mimeTypes.rdf (new Type File zz, action sublime-text)
I change extension .txt files on .zz
Put in end line:
file:///path/file.zz
Use asciidoc to create html files.
So, then I click on link, text editor open with file.zz :)

Now I can quickly and just as I edit the files.
Achieved his goal.

But I'm wonder how to execute local bash script in firefox something like:
bash://path-to-script.bash in url bar.

unSpawn 02-15-2013 09:59 AM

See the link TB0ne posted in post #2.

TB0ne 02-15-2013 10:20 AM

Quote:

Originally Posted by inkscape (Post 4892322)
I edit firefox mimeTypes.rdf (new Type File zz, action sublime-text)
I change extension .txt files on .zz
Put in end line:
file:///path/file.zz
Use asciidoc to create html files.
So, then I click on link, text editor open with file.zz :)

Now I can quickly and just as I edit the files.
Achieved his goal.

But I'm wonder how to execute local bash script in firefox something like:
bash://path-to-script.bash in url bar.

Don't know why you're wondering...you've been pointed to how to do it a few times now. That page is very, VERY clear, and has examples.

corp769 03-03-2013 11:24 AM

This is off topic, but I vote this thread for the "Best of 2013" award.

amar@solus 05-28-2013 12:39 AM

how to execute/ run a linux commond from HTML page..?
In my project I have to run a unix commond from html page to change my IP address of my target board.
can some one suggest me how to achieve this.


All times are GMT -5. The time now is 03:00 PM.