LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-14-2013, 08:38 AM   #1
inkscape
Member
 
Registered: Dec 2011
Distribution: Slackware 14.1
Posts: 33

Rep: Reputation: Disabled
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?
 
Old 02-14-2013, 09:16 AM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,124

Rep: Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456
Quote:
Originally Posted by inkscape View Post
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/
 
Old 02-14-2013, 09:36 AM   #3
inkscape
Member
 
Registered: Dec 2011
Distribution: Slackware 14.1
Posts: 33

Original Poster
Rep: Reputation: Disabled
I don't want php/java. I rather think about something like this:
http://askubuntu.com/questions/16155...a-shell-script
 
Old 02-14-2013, 10:25 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,944
Blog Entries: 54

Rep: Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731
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.
 
Old 02-14-2013, 10:49 AM   #5
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,124

Rep: Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456
Quote:
Originally Posted by inkscape View Post
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.
 
Old 02-14-2013, 12:53 PM   #6
inkscape
Member
 
Registered: Dec 2011
Distribution: Slackware 14.1
Posts: 33

Original Poster
Rep: Reputation: Disabled
@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).
 
Old 02-14-2013, 02:01 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,944
Blog Entries: 54

Rep: Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731
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?
 
Old 02-14-2013, 02:08 PM   #8
inkscape
Member
 
Registered: Dec 2011
Distribution: Slackware 14.1
Posts: 33

Original Poster
Rep: Reputation: Disabled
because I want use firefox and I do not want to get around the problem
 
Old 02-14-2013, 02:33 PM   #9
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,124

Rep: Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456
Quote:
Originally Posted by inkscape View Post
@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.

Last edited by TB0ne; 02-15-2013 at 09:05 AM.
 
Old 02-15-2013, 12:43 AM   #10
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,225

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
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
 
Old 02-15-2013, 09:43 AM   #11
inkscape
Member
 
Registered: Dec 2011
Distribution: Slackware 14.1
Posts: 33

Original Poster
Rep: Reputation: Disabled
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.
 
Old 02-15-2013, 09:59 AM   #12
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,944
Blog Entries: 54

Rep: Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731
See the link TB0ne posted in post #2.
 
Old 02-15-2013, 10:20 AM   #13
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,124

Rep: Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456Reputation: 2456
Quote:
Originally Posted by inkscape View Post
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.
 
Old 03-03-2013, 11:24 AM   #14
corp769
Guru
 
Registered: Apr 2005
Posts: 5,807

Rep: Reputation: 995Reputation: 995Reputation: 995Reputation: 995Reputation: 995Reputation: 995Reputation: 995Reputation: 995
This is off topic, but I vote this thread for the "Best of 2013" award.
 
Old 05-28-2013, 12:39 AM   #15
amar@solus
LQ Newbie
 
Registered: Mar 2013
Posts: 10
Blog Entries: 1

Rep: Reputation: Disabled
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to run a script on host machine from a webpage MetaMan Linux - Server 5 07-27-2011 12:39 PM
[SOLVED] Run multiple bash and php scripts from a bash script charu Programming 5 07-26-2011 02:40 AM
Run My CGI Script from Webpage mykolg Linux - Server 6 01-17-2011 02:17 AM
My BASH script work perfect when i run it manualy, but not when it run in the crontab roqarg Linux - Newbie 30 05-06-2010 01:37 PM


All times are GMT -5. The time now is 12:20 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration