The error code if the script fails to run is return in the webpage like this<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquer +y.min.js"></script> <script> $(document).ready(function() { $('input').keyup(function() { var empty = false; $('input').each(function() { if ($(this).val().length == 0) { empty = true; } }); if (empty) { $('.actions input').attr('disabled', 'disabled'); } else { $('.actions input').attr('disabled', false); } }); $("#btnSearch").click(function(event) { var term = $("#urlField").val(); perlExecute(term); }); function perlExecute(term){ $.ajax({ type: 'POST', url: '/cgi-bin/domain-.pl', data: { 's': term }, success: function(res) { $("#result").text(res); }, error: function() {$("#result").text("Search Failed\nPossible +reasons:-\nThere illegal characters in your search.)");} }); }; }); </script> </head> <body> <div class='form'> <input type="text" name="s" placeholder="Search..." id="urlField +"> <div class='actions'> <input type="button" value="Search" id="btnSearch" disabled="dis +abled" > </div> </div> <div id="result"></div> <p id="content">Lorem Ipsum</p> </body> </html>
With no recognition of the my new-line characters or the other extreme isSearch Failed Possible reasons:- There illegal characters in your sear +ch
With my new-line characters printed in the text. - how can I format the error text the way i want it to appear? The other issue is that the command being run is["Search Failed\nPossible reasons:-\nThere illegal characters in your +search."]
The above code prints out the following#!/usr/bin/perl -w use warnings; use JSON; use CGI; my $cgi = CGI->new(); my $string = $cgi->param('s'); $ns_lookup = `dig \@4.2.2.2 +norecurse +nocmd +noquestion +nostats +no +comments +authority +noadditional $domain NS`; chomp($ns_lookup); print "Content-type: text/html\n\n"; print $ns_lookup;
Instead ofgoogle.co.zw. 59751 IN NS ns3.google.com. google.co.zw. 59751 IN NS ns +4.google.com. google.co.zw. 59751 IN NS ns1.google.com. google.co.zw. + 59751 IN NS ns2.google.com.
how can i format the text and make it more legible.google.co.zw. 59751 IN NS ns3.google.com. google.co.zw. + 59751 IN NS ns4.google.com. google.co.zw. 59751 IN + NS ns1.google.com. google.co.zw. 59751 IN NS ns2.goog +le.com.
In reply to Format script out in JSON for webpage by HBMBR
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |