Avatar of Tater73
Tater73Flag for Afghanistan

asked on 

Grep output to a webpage

I need to write a script/utility that will allow the user to input a hostname thru a web interface that will grep the /etc/hosts file and display the output to a webpage.
Unix OS

Avatar of undefined
Last Comment
Julian Parker
ASKER CERTIFIED SOLUTION
Avatar of wesly_chen
wesly_chen
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Julian Parker
Julian Parker
Flag of United Kingdom of Great Britain and Northern Ireland image

you will probably need to add;

echo "Content-type: text/plain"
echo ""

after the #!/bin/bash so the browser knows how to deal with it or you may get a bad header.

I'm not suggesting you should use `isindex` most places suggest you use a form.

You should take care about validating inputs, it may be possible to enter some query that compromises the system, that said it does work.
Unix OS
Unix OS

Unix is a multitasking, multi-user computer operating system originally developed in 1969 at Bell Labs. Today, it is a modern OS with many commercial flavors and licensees, including FreeBSD, Hewlett-Packard’s UX, IBM AIX and Apple Mac OS-X. Apart from its command-line interface, most UNIX variations support the standardized X Window System for GUIs, with the exception of the Mac OS, which uses a proprietary system.

33K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo