How to run my shell script from windows Webpage? - windows

I want to execute some batch jobs from my unix box thro shell scripts.
Scenario:
I have some shell scripts in my unix box, want to run those scripts thro my windows webpage. This is to achieve by click on a button from the webpage.
Thanks in Advance.

The messy way:
Set up a web server on the unix box, use whatever programming language you fancy (say, PHP, Python, Perl) to generate a suitable web page, and make it do a system call to your script when it sees a postback. A very dumbed-down example in PHP:
<?php
if (isset($_POST['do_it'])) {
$result = `my_super_shell_script.sh`;
}
?>
<html>
<head><title>Run a script</title></head>
<body>
<form method="POST" action="">
<button type="submit" name="do_it" value="1">Do It!</button>
</form>
<pre>
<?php echo $result; ?>
</pre>
</body>
</html>
This, however, is full of problems. Most of all security: Anyone who can send a post request to your page can trigger the script, which is not usually what you want. You'll have to take extra measures to make sure nobody can access the page without prior authorization.
The nice solution:
Just use ssh. It doesn't give you a web site, but using PuTTY (or any other ssh client), you can simply log into the Unix box without exposing it to the whole world.

Related

How to redirect the visitors to another site in Middleman?

Redirecting to another site was very easy in PHP. If they wanted to redirect visitors from "www.yoursite.com/news" to "www.bbc.com"...all I had to do was make the "news" folder and create an index.php file in it and add this line:
<?php
header("Location: http://www.bbc.com/");
?>
And I was done! But I recently started working on a project written in Ruby, and having trouble to figure out how to achieve this simple task :<
This might be a very silly question, but any help will be greatly appreciated!!
UPDATE:
So found out that this project is using static site generator Middleman to build the site, that's why there is no routes.rb file. It only has config.rb. Can anyone please help me to figure out how to redirect in middleman?
2nd UPDATE:
Looks like because of Middleman, this redirecting isn't possible that simply. So I am asking this (very dumb) question: How to redirect URL in Javascript or jQuery
So finally found an easy solution to my problem :)
In order to redirect www.yoursite.com/news to www.bbc.com, first I created a news.html.erb file under my source folder (where you have your index.html.erb file). And in that file I added the following lines and wallaaahhhh!
<% content_for :body_content do %>
<script type="text/javascript">
// Javascript URL redirection
window.location.replace("http://www.bbc.com/");
</script>
<noscript>
// Using HTML refresh meta tag as a fail back in case the user has javascript disabled
<meta http-equiv="refresh" content="0;URL=http://www.bbc.com/">
</noscript>
<% end %>
One thing I should mention here is that most sites suggested
using window.location.href, because replace() does not put the originating page in the session history, meaning the user won’t get stuck in a never-ending back-button process.
But in my case window.location.href wasn't doing the trick :(
You'll need to setup a custom route in routes.rb:
get "/news" => redirect("http://bbc.com")

how to send file data using Dajaxice?

I am using ajax for my website. I have successfully used jQuery.ajax() to asynchronously upload file to server. I am using Dajax and Dajaxice therefore I plan to use these application for file upload as well. I tried this example. It is working fine. But if I add file field into my html form, it does not send file to server. My html form looks like
<form id="myform" action="/file/" method="post" enctype="multipart/form-data">
<div style='display:none'><input type='hidden' name='csrfmiddlewaretoken' value='AaSmyBEwQLSD3YghRAD9Cf2uxEjzESUe' /></div>
<p><label for="id_docfile">Select a file</label> max. 42 megabytes</p>
<p><input type="file" name="docfile" id="id_docfile" /></p>
<p><input type="submit" value="Upload" /></p>
</form>
This question has been asked at many place but never answered.
Afaik there is currently no provision within dajax / dajaxice to upload files.
I have used dajax in a few projects and have got round this by using blueimp/jquery-file-upload and a django view that accepts a POST of the upload file and return a JSON string to the client.
This is a less than perfect solution not least because the jquery-file-upload button is styled differently from normal html form elements, it is possible to style the whole form using jQuery-ui, although this is a lot of additional work.
Both, dwr which is pretty much dajax for Java, and tasty pie for django do offer file uploading, so in theory it should be possible to implement it.
I'm happy to post a sample of my ajax solution if anyone would find them useful.
I've also faced this problem recently. So, I've digged a little and discovered some answers.
It is working fine. But if I add file field into my html form, it does not send file to server.
There's serialize() method used in the doc example. But according to the jQuery doc:
Data from file select elements is not serialized.
Also, there's no clear way to get ajax file upload, because JS doesn't have access to the outside of the client browser. So, I don't think it's possible to make using dajaxice.
The easiest hack, I've found is to post form to the invisible iframe using target option:
<form method='POST' action='/upload' enctype='multipart/form-data' target='submit-iframe'>
so, only the iframe will be refreshed. Using js you than can get data from it catching the load() event.
More detailed process described here

AJAX Wordpress Site with Difficult URL settings

On this WordPress theme utilizing AJAX, proves to be difficult. The developer of the theme cannot seem to find the issue or solution to it.
This site runs beautifully, if, and only IF, you type is this complete URL "http://www.geigerandwood.com/#!//" if you type in the .com site alone, it will appear but will be disfunctional.
I have made attempts in 301 redirects, even creating a static page with a redirect but still no luck. Is there something that I can add or change in the code to make this work properly?
FYI - it has been tested on the common web browsers on both OSX & Windows.
Here is a video of my presented issue. http://www.screenr.com/D1G8
What theme do you use?
My quick examination of your page source code is that I only can find something related to the #!// is in here
<div id="contentBoxScroll">
<a id="closeButton" href="#!//"></a>
<div class="dragcontainer">
<div id="contentBoxScrollDragger" class="dragger">
<div class="scroll_up"></div>
<div class="scroll_down"></div>
</div>
</div>
</div>
I assume it must be something inside the script from which that HTML is generated. I can say more since I can't see the full source.

Ajax update in a Sharepoint 2010 Webpart

Is there any easy way to make a Ajax call in a Webpart?
I have a Webpart with a button, and I want that when the user pushes the button, it executes a server function without reloading the page. And then, if all is ok, execute a callback function. I thought that the best way is with a AJAX call.
But when I've looked for how to do it I only get some complicated tutorials that I don't really understand (and most are from old versions of Sharepoint). Any help? What is the best way to start? Thanks
Have you tried using jQuery with a content editor web part? I've done this before and it's rather easy. Here is a step by step for how I do it.
Download jQuery.
Upload jQuery to SiteAssets in Sharepoint.
Upload coded file (see below) with AJAX calls.
Point to coded file via Content Editor Web Part.
It should work!
Here is a default way something should work.
<html>
<head>
<script src="<point to jquery file>"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#main').load('<RELATIVE URL TO SERVER PAGE>');
});
</script>
</head>
<body>
<div id="main"></div>
</body>
</html>
If possible I would go for a Visual Web Part in Visual Studio. You basically create a .NET user control. It saves you a lot of manual control definitions etc.
If in SharePoint2007 you might want to take a look at the "Smartpart". It has ajax support and some great tutorials on how to use it.

Open pop-up windows info, after client logout

I'm trying to do something that should be quite easy, but after a while I realize that can be tricky in Magento.
So, my goal is pop-up (or pop-down) an windows that display information for the client that just logout. In my logout Success it just redirect to main page after 5 seconds.
The correct place to do it in the code/file I suppose that will be here (logout.phtml):
<div class="page-title">
<h1><?php echo Mage::helper('customer')->__('You are now logged out') ?></h1>
</div>
<p><?php echo Mage::helper('customer')->__('You have logged out and will be redirected to our homepage in 5 seconds.') ?></p>
<script type="text/javascript">
//<![CDATA[
setTimeout(function(){ location.href = '<?php echo $this->getUrl() ?>'},5000);
//]]>
</script>
Thanks in advance for any help.
You should be able to do what you are trying to do by editing that template. Does your JS code not end up being output? If not, make sure you are editing the right logout.phtml, depending on how your themes are setup there could be several. There's a developer setting to show the full path to blocks when viewing a page, that can be very helpful in making sure you are editing the correct template.
Also, I'm not sure if your JS code is just a test to see if it's being output, but it doesn't look like it would popup a window even if it were correctly output. The code looks like it would just redirect the user back to the main page of your site.
If you're looking for the JS code to create a popunder window, then something basic like this should work:
window.open('http://yoursite.com/popunder.html','Pop Under Window','').blur();
window.focus();
You can set the window attributes as you see fit by using the 3rd parameter of the open function.

Resources