Reputation: 119
Is there any way to get JavaScript to run apt-get install gimp
on the user's computer when on a link click so that, The user will know the software is being installed.
I've tried googling it.
If there is no way of doing this, please say as after a day, I will mark it as the answer.
Upvotes: 1
Views: 468
Reputation:
Hmm No, It is not possible to run a shell command on the clients computer directly from JavaScript. Sure there are JavaScript shell functions but they are limited to what they can do. But under no circumstance does a client side code on the web has the authority to access a root level command such as apt-get install.
You could possibly write a python/ruby/perl script that does that. Have the user download it and execute it manually.
Aside from that I'm sorry buddy, its simply not possible (at least from what I've read throughout the years on the web).
Upvotes: 1
Reputation: 136
Few answers above mention that if it exists, then it will be unsafe. But the fact is that there is an existing solution already for ubuntu and its safe too.
The mechanism is called apturl. see here:
https://help.ubuntu.com/community/AptURL
https://wiki.ubuntu.com/AptUrl
It is supported by firefox, konqueror atleast. It needs "apturl" package to be installed(which is installed by default ). When user click on apt-url link as shown in answer above by @atrepp , then the defult package launcher will start to install with asking for appropriate authorization(password), as if you would have clicked in "Ubuntu Software Center". Its completely safe as much as you would have installed via "Ubuntu Software Center" or "apt-get" directly.
And i am confident that no such solution exists for RHEL or SuSE.
Upvotes: 2
Reputation: 2122
there is link shortcut for that on ubuntu :
<a href="apt://gimp" title="apt://gimp" rel="nofollow">gimp</a>
but it does not install automatically, it just launch the package manager
Upvotes: 3
Reputation: 3441
if you could do that I will never use the internet because it will be full of spams.
javascript and all the client side scripts have very limited privileges, so making a shell command is impossible
Upvotes: 2
Reputation: 1839
If this would be possible, it would be a huge security issue! Just imagine a similar link, but running something like rm -rf ~
... As far as I know, JavaScript in browsers has no support for child process creation.
On the other hand, Java is able to create child processes (as your apt-get), so you might use a (signed) Java applet for this; in that case, the user will be prompted to authorize the applet to run, to make him aware of the potential security risk.
Upvotes: 2