Sponsored Content
Top Forums Shell Programming and Scripting Running shell scripts from web browser Post 302082198 by System Shock on Monday 31st of July 2006 05:02:32 PM
Old 07-31-2006
I'm sure you can find plenty of tutorials on cgi on the web, although I don't know about tutorials using shell scripts; most use perl, asp, etc... anyway, continuing with the example above, forgot to mention that the form passes the variable NAME to myscript.cgi as a string, not as a variable. It's an important difference because myscript.cgi needs to read the string and make it a variable.

Let me tell you what myscript.cgi does, so you'll get a better idea, and can use it as a base for what you want to do. A user goes to the web page, and enters an ID. This ID is going to be appended to an access file to allow the user WAP access to several web applications.
myscript.cgi looks something like this:

Code:
#!/usr/bin/ksh
echo "content-type: text/plain"
echo
read USERID?   ## this reads the NAME variable passed by the web form
echo ${USERID} > /opt/apache/htdocs/application/temp/userID
NEWID=$(sed 's/NAME=//' /opt/apache/htdocs/application/temp/userID) ## this cleans the string that was passed by the form
echo ${NEWID} by ADMIN  >> /opt/apache/htdocs/application/access.dat.req  ## access.dat.req is read by a cronjob every night

## This part will actually generate a web page that will inform the user that  his/her ID was submitted

echo "<html> <body BGCOLOR="#000000" TEXT="#ddd20f">"
echo "<FONT FACE="Trebuchet MS">"
echo "<center><p><big>userID ${NEWID} has been recorded</big><br>"
echo "</p>"
echo "userIDs submitted before 7:00PM ET are<BR>"
echo " activated the same day after 9:00PM ET<BR>"
echo "<BR>"
echo "For any issues with this tool, please open <BR>"
echo " a ticket in the application queue<BR>"
echo "</FONT>"
echo "</center></body></html>"

I don't know how big your csv files are, or how you want to display them, or what data is input by the web user. However, these snippets show you how to get data from the web form, how to run commands based on that data, and how to display the processed data immediately on your web browser after the data has been processed. At its most basic, you could make a variable like myCSV=$(cat file.csv), then

echo opening html tags,
echo ${myCSV}
echo closing html tags

and that should display your csv on the web.

Oh, and before I forget, you may have to tweak the script depending what browser you use. I did this one for corporate, so it works with IE, and the mozilla browser that come with Solaris 10 (which I use ). I didn't test it for any other browsers.

Last edited by System Shock; 07-31-2006 at 06:15 PM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Cron running shell scripts.

What are the rules of calling shell scripts in cron. How do I go about setting up the correct PATHS that calls a script, which then calls another sub script all of which has to retain the orginal PATHS and VARS that I've set up in first script Confused.. ok Well Cron calls a script... (3 Replies)
Discussion started by: cfoxwell
3 Replies

2. UNIX for Dummies Questions & Answers

Running shell scripts on a remote server

Hi - I am running Mac OS X (Terminal) at my current workstation, and I would like to telnet to my local server to run a shell script. The local server is a Solaris machine (don't know the version or the type of Unix being run on it, sorry.) The problem I have is that when I create a #!/bin/sh... (2 Replies)
Discussion started by: pepintheshort
2 Replies

3. UNIX for Dummies Questions & Answers

Web browser and web server for Unix

Hi there all I am looking for both a web browser as well as a web server (Ie. Netscape Fasttrack) that will run on HPUX 10. If you know where I can get these free via FTP, please contact me as soon as possible!! Thanks, Mark (1 Reply)
Discussion started by: mleathers
1 Replies

4. UNIX for Dummies Questions & Answers

running vendor shell scripts

Does anyone run a lot of SH (shell script) commands from vendors. i.e... product installations. And do you edit/change as a rule of thumb? I done a lot of product installs and some tend to think we should edit/change a vendors SH script. I am just looking for your thoughts. Thanks. (1 Reply)
Discussion started by: Javagate
1 Replies

5. Shell Programming and Scripting

running shell script thru WEB page ....

....passing variable via list... here 's the HTML code extract : **************** <form method=post action=http://servername/cgi-bin/cgi-comptage_diff.ksh> <table border...........> .............. </table> <table bgcolor=#FFFFFF width="980"> ... (6 Replies)
Discussion started by: Nicol
6 Replies

6. UNIX for Advanced & Expert Users

unix shell scripts for running on solaris

am new to programmming any body suggest , how to execute, shell script interactively and like stream line edit (3 Replies)
Discussion started by: srini_ibmadmin
3 Replies

7. Shell Programming and Scripting

executing shell scripts in a browser

Hi all Im a newbie in shell scripting, i found it joyous creating simple adminitrative scripts, like adding users, modify and delete, remote sw install etc, now i want to intergrate my scripts to make a simple administrative tool, how do i access the scripts via a browser is it possible?? ... (2 Replies)
Discussion started by: jefinah
2 Replies

8. Shell Programming and Scripting

Automatic running of Shell scripts

Hi, I have this problem of merging 2 shell scripts and run it one after the other. For eg: script A runs to give OutputA. This OutputA should become the input of script B which will run to give OuputB. Now this has to happen automatically i.e, script A and script B should run consecutively one... (1 Reply)
Discussion started by: Vindhyaauri
1 Replies

9. Shell Programming and Scripting

Running shell scripts from command

I have written a few shellscripts to run a videogame (starcraft) at different patched versions. For example bw113 runs the 1.13 version of the game. These works perfectly when I run them from command line (./bw113). However I cannot get it to work via mouseclick. Some Information: - I have... (5 Replies)
Discussion started by: lordsloth
5 Replies
NPM-RUN-SCRIPT(1)														 NPM-RUN-SCRIPT(1)

NAME
npm-run-script - Run arbitrary package scripts SYNOPSIS
npm run-script <command> [--silent] [-- <args>...] alias: npm run DESCRIPTION
This runs an arbitrary command from a package's "scripts" object. If no "command" is provided, it will list the available scripts. run[-script] is used by the test, start, restart, and stop commands, but can be called directly, as well. When the scripts in the package are printed out, they're separated into lifecycle (test, start, restart) and directly-run scripts. As of ` https://blog.npmjs.org/post/98131109725/npm-2-0-0, you can use custom arguments when executing scripts. The special option -- is used by getopt https://goo.gl/KxMmtG to delimit the end of the options. npm will pass all the arguments after the -- directly to your script: npm run test -- --grep="pattern" The arguments will only be passed to the script specified after npm run and not to any pre or post script. The env script is a special built-in command that can be used to list environment variables that will be available to the script at run- time. If an "env" command is defined in your package, it will take precedence over the built-in. In addition to the shell's pre-existing PATH, npm run adds node_modules/.bin to the PATH provided to scripts. Any binaries provided by locally-installed dependencies can be used without the node_modules/.bin prefix. For example, if there is a devDependency on tap in your package, you should write: "scripts": {"test": "tap test/*.js"} instead of "scripts": {"test": "node_modules/.bin/tap test/*.js"} to run your tests. The actual shell your script is run within is platform dependent. By default, on Unix-like systems it is the /bin/sh command, on Windows it is the cmd.exe. The actual shell referred to by /bin/sh also depends on the system. As of ` https://github.com/npm/npm/releases/tag/v5.1.0 you can customize the shell with the script-shell configuration. Scripts are run from the root of the module, regardless of what your current working directory is when you call npm run. If you want your script to use different behavior based on what subdirectory you're in, you can use the INIT_CWD environment variable, which holds the full path you were in when you ran npm run. npm run sets the NODE environment variable to the node executable with which npm is executed. Also, if the --scripts-prepend-node-path is passed, the directory within which node resides is added to the PATH. If --scripts-prepend-node-path=auto is passed (which has been the default in npm v3), this is only performed when that node executable is not found in the PATH. If you try to run a script without having a node_modules directory and it fails, you will be given a warning to run npm install, just in case you've forgotten. You can use the --silent flag to prevent showing npm ERR! output on error. You can use the --if-present flag to avoid exiting with a non-zero exit code when the script is undefined. This lets you run potentially undefined scripts without breaking the execution chain. SEE ALSO
o npm help 7 scripts o npm help test o npm help start o npm help restart o npm help stop o npm help 7 config January 2019 NPM-RUN-SCRIPT(1)
All times are GMT -4. The time now is 05:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy