Thread View: comp.unix.misc
5 messages
5 total messages
Started by David Winter
Tue, 23 Oct 2001 09:30
How to launch a shell script (.sh) from an HTML page ?
Author: David Winter
Date: Tue, 23 Oct 2001 09:30
Date: Tue, 23 Oct 2001 09:30
41 lines
2632 bytes
2632 bytes
Hi,
I'm sure somebody already posted the solution some time ago, but I couldn't
find it.
I need to launch a sheel script (.sh file) from an HTML page under unix
(Solaris and others).
I am NOT using any server: this only a LOCAL html page. No virtual
directories.
Right now I am using the following code, that is executed from an image
button in an HTML <form>:
<script>
function openMyFile ()
{
if (document.layers)
{
var exePath = new String('. ./test.sh');
netscape.security.PrivilegeManager.enablePrivilege('UniversalExecAccess');
java.lang.Runtime.getRuntime().exec(exePath);
}
}
</script>
The test.sh file changes the current directory in order to run another sh
that launches a java application.
I have tried several shell commands, such as:
'. ./test.sh'
'./test.sh'
but no luck. Nothing happens and my sh file is not launched.
Any ideas ? Please reply in this newsgroup.
Thank you for your help,
David Winter
Re: How to launch a shell script (.sh) from an HTML page ?
Author: Keith Duffin
Date: Tue, 23 Oct 2001 11:49
Date: Tue, 23 Oct 2001 11:49
55 lines
3144 bytes
3144 bytes
Shell can be used out of the box by apache as a cgi. Just drop a shell
script in your cgi directory. The most common problem is the "malformed
header". Just be sure to give it a plain text header:
#!/bin/sh
echo "Content-type: text/plain\n\n"
/bin/ls
Take Care, Keith
"David Winter" <noemail@nospam.com> wrote in message
news:9r3fue$6k5$1@news.businessobjects.com...
> Hi,
>
> I'm sure somebody already posted the solution some time ago, but I
couldn't
> find it.
> I need to launch a sheel script (.sh file) from an HTML page under unix
> (Solaris and others).
> I am NOT using any server: this only a LOCAL html page. No virtual
> directories.
>
> Right now I am using the following code, that is executed from an image
> button in an HTML <form>:
>
> <script>
> function openMyFile ()
> {
> if (document.layers)
> {
> var exePath = new String('. ./test.sh');
>
> netscape.security.PrivilegeManager.enablePrivilege('UniversalExecAccess');
> java.lang.Runtime.getRuntime().exec(exePath);
> }
> }
> </script>
>
>
> The test.sh file changes the current directory in order to run another sh
> that launches a java application.
>
> I have tried several shell commands, such as:
>
> '. ./test.sh'
> './test.sh'
>
> but no luck. Nothing happens and my sh file is not launched.
> Any ideas ? Please reply in this newsgroup.
>
>
> Thank you for your help,
>
> David Winter
>
>
Re: How to launch a shell script (.sh) from an HTML page ?
Author: Alex Mitrofanov
Date: Tue, 23 Oct 2001 17:41
Date: Tue, 23 Oct 2001 17:41
84 lines
3643 bytes
3643 bytes
David Winter wrote:
>
> Hi,
>
> I'm sure somebody already posted the solution some time ago, but I couldn't
> find it.
> I need to launch a sheel script (.sh file) from an HTML page under unix
> (Solaris and others).
> I am NOT using any server: this only a LOCAL html page. No virtual
> directories.
>
> Right now I am using the following code, that is executed from an image
> button in an HTML <form>:
>
> <script>
> function openMyFile ()
> {
> if (document.layers)
> {
> var exePath = new String('. ./test.sh');
You can't use `.', it is a sell command.
>
> netscape.security.PrivilegeManager.enablePrivilege('UniversalExecAccess');
> java.lang.Runtime.getRuntime().exec(exePath);
> }
> }
> </script>
>
> The test.sh file changes the current directory in order to run another sh
> that launches a java application.
>
> I have tried several shell commands, such as:
>
> '. ./test.sh'
> './test.sh'
Are you sure netscape's current directory is where you put your script?
Try this page:
<html>
<head>
<script>
function openMyFile ()
{
if (document.layers)
{
var exePath = new String('/full/path/to/test.sh');
netscape.security.PrivilegeManager.enablePrivilege('UniversalExecAccess');
java.lang.Runtime.getRuntime().exec(exePath);
}
}
</script>
</head>
<body onload="openMyFile()">
</body>
</html>
and script:
#!/bin/sh
cd /usr/X11R6/bin
./xterm
Don't forget to give execution permission.
If it works modify it for your needs.
>
> but no luck. Nothing happens and my sh file is not launched.
Look in javascript console, you can open it by typing `javascript:' in
the location field.
> Any ideas ? Please reply in this newsgroup.
Which one? I've set follow-ups to comp.unix.questions.
HTH,
--
Alex Mitrofanov
Brainbench MVP for Unix Programming
http://www.brainbench.com
Re: How to launch a shell script (.sh) from an HTML page ?
Author: Bill Vermillion
Date: Wed, 24 Oct 2001 22:59
Date: Wed, 24 Oct 2001 22:59
21 lines
2203 bytes
2203 bytes
In article <9r3fue$6k5$1@news.businessobjects.com>, David Winter <noemail@nospam.com> wrote: >I need to launch a sheel script (.sh file) from an HTML page under unix >(Solaris and others). >I am NOT using any server: this only a LOCAL html page. No virtual >directories. ... >The test.sh file changes the current directory in order to run another sh >that launches a java application. The proper place to run executables is from the cgi-bin directory or the place designated as such in your config files. This may not make a difference but coalesecing all your executeables in one area makes for good security too. -- Bill Vermillion - bv @ wjv . com
Re: How to launch a shell script (.sh) from an HTML page ?
Author: Chris F.A. Johnson
Date: Mon, 29 Oct 2001 20:01
Date: Mon, 29 Oct 2001 20:01
21 lines
2847 bytes
2847 bytes
On Mon, 29 Oct 2001, Hactar wrote:
> In article <BPcB7.1463$jr.299765@news1.rdc1.va.home.com>,
> Keith Duffin <keith@duffin.org> wrote:
> > Shell can be used out of the box by apache as a cgi. Just drop a shell
> > script in your cgi directory.
>
> There is only a cgi directory if there is a web server. The OP said this is
> a local page (i.e., no web server); right, OP? You're using some kind of
> file:// URL to view this file, yes? I don't know how to do it without a
> web server. With a web serber, Keith's right; you just put it in /cgi-bin
> or wherever cgis are kept. The script should output HTML.
The script need not output HTML; it can be anything (plain text, images,
etc.), so long as the header identifies the correct type.
--
Chris F.A. Johnson http://cfaj.freeshell.org
===================================================================
My code (if any) in this post is copyright 2001, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads