I am trying to execute shell commands or shell script through onclick function in HTML button. For eg:
<button type="button" onclick="/path/to/name.sh">Click Me!</button>
Is there any way to do so or some other way around?
This question has already been asked. Check the below link.
Run a shell script with an html button
The method posted may be feasible with some tweaks in Apache, but it is not the most common way of running a shell script.
If you are using PHP, you can use system(), exec(), popen(), etc... and the path to your file ex:
exec('/path/to/file.sh');
You need to make sure of two things first:
The users you are running as has the proper permissions to execute the shell file.
exec() is not listed as a disabled function in the php.ini (normally, some hosting providers disable them for security issues).
Related
I have downloaded the BaseElements plugin for Filemaker and managed to get it installed, I have downloaded this specifically to make use of "BE_ExportFieldContents" (https://baseelementsplugin.zendesk.com/hc/en-us/articles/204700538-BE-ExportFieldContents) which basically allows me to export from a Container field on a server side script. I have looked through the documentation and cannot seem to find help.
Now I have the function, I'm completely at a loss on how to actually call the function? I want to export something from the container file to the filemaker documents path - so my question is, where and how the hell do I use this function in Filemaker? Apologies in advance for the noob question.
You make a script where you call this function from the record in question. This script can be run in the client, or via a schedule on FileMaker Server or via the Perform Script on Server script step.
The syntax is like this:
BE_ExportFieldContents ( field ; outputPath )
Where the ‘field’ parameter is the container field and the ‘outputPath’ is where you want the file to end up.
Usually you call such functions via the Set Variable script step. After the execution the variable contains any error or result from the call.
Note that the plugin needs to be installed and enabled on the server for it to work there.
I already know how to make a function in powershell. The problem is: How do I save that function so I can use it in the future?
When I write myFunction{3+3} in Powershell I can use that function in that session.
Altough, if I quit powershell and open it again, that function is gone. How do I "save" the function so I can use it even after I restart Powershell?
There are several ways:
You can compose it to a module and load it with import-module functions.psm1 into a script or via use the ps profile.
You can also dot sourc any saved functions into another ps1 ( . .\functions.ps1).
Put it in your Powershell profile:
Rather than explain it here, try this article:
http://www.howtogeek.com/50236/customizing-your-powershell-profile/
Is there some way to run a command line tool from a client-side script? I want to do something like this:
myutility -flag1 -flag2 inputfile outputfile
with a script in the head of an html file. Is there a way to do it, preferably with JS in Safari?
Yes. That script, myutility needs to be compatible with the server machine your webserver is running on, as well as the script needs to have the correct execution rights. Let me know what kind of script it is so that I can help further, is it a bash script you are trying to run? Perhaps you could do that within your server side language, ie php to make things easier?
I'm trying to write a GUI using Tcl/tk where the user will select different parameters and hit a 'Submit' button. When the button is pressed, the program will open an xterm window and telnet and perform configurations based on the choices made by the user. I know this should be pretty basic but I've looked everywhere and cannot find a working method. Please advise. Thanks.
I think xterm isn't needed: Expect is able to provide a program (telnet in your case) with a pseudoterminal -- one of the things xterm does for the program it's running. So just google for this combo.
I don't believe that expect can control an X app such as xterm. It can however control a text app like telnet.
You can write a shell script that launches xterm, passing the "-e" option to execute an expect script. That expect script can then launch telnet.
I am trying to write a script that will parse a local file and upload its contents to a MySQL database. Right now, I am thinking that a batch script that runs a Perl script would work, but am not sure if this is the best method of accomplishing this.
In addition, I would like this script to run immediately when the data file is added to a certain directory. Is this possible in Windows?
Thoughts? Feedback? I'm fairly new to Perl and Windows batch scripts, so any guidance would be appreciated.
You can use Win32::ChangeNotify. Your script will be notified when a file is added to the target directory.
Checking a folder for newly created files can be implemented using the WMI functionality. Namely, you can create a Perl script that subscribes to the __InstanceCreationEvent WMI event that traces the creation of the CIM_DirectoryContainsFile class instances. Once that kind of event is fired, you know a new file has been added to the folder and can process it as you need.
These articles provide more information on the subject and contain VBScript code samples (hope it won't be hard for you to convert them to Perl):
How Can I Automatically Run a Script Any Time a File is Added to a Folder?
WMI and File System Monitoring
The function you want is ReadDirectoryChangesW. A quick search for a perl wrapper yields this Win32::ReadDirectoryChanges module.
Your script would look something like this:
use Win32::ReadDirectoryChanges;
$rdc = new Win32::ReadDirectoryChanges(path => $path,
subtree => 1,
filter => $filter);
while(1) {
#results = $rdc->read_changes;
while (scalar #results) {
my ($action, $filename) = splice(#results, 0, 2);
... run script ...
}
}
You can easily achieve this in Perl using File::ChangeNotify. This module is to be found on CPAN: http://search.cpan.org/dist/File-ChangeNotify/lib/File/ChangeNotify.pm
You can run the code as a daemon or as a service, make it watch one or more directories and then automatically execute some code (or start up a script) if some condition matches.
Best of all, it's cross-platform, so should you want to switch to a Linux machine or a Mac, it would still work.
It wouldn't be too hard to put together a small C# application that uses the FileSystemWatcher class to detect files being added to a folder and then spawn the required script. It would certainly use less CPU / system resources / hard disk bandwidth than polling the folder at regular intervals.
You need to consider what is a sufficient heuristic for determining "modified".
In increasing order of cost and accuracy:
file size (file content can still be changed as long as size is maintained)
file timestamp (If you aren't running ntpd time is not monotonic)
file sha1sum (bulletproof but expensive)
I would run ntpd, and then loop over the timestamps, and then compare the checksum if the timestamp changes. This can cover a lot of ground in little time.
These methods are not appropriate for a computer security application, they are for file management on a sane system.