cgi script and external UNIX commands (like swadm)


 
Thread Tools Search this Thread
Top Forums Web Development cgi script and external UNIX commands (like swadm)
# 1  
Old 05-29-2011
cgi script and external UNIX commands (like swadm)

Hi,
I am trying to implement a server monitoring dashboard using cgi scripting. I am planning to run the necessary unix scripts from the web page using cgi. This method works fine for standard unix commands but I am unable to run some external unix commands (like swadm show_processes, swadm count_messages etc). These commands work fine as ordinary shell scripts, but fail in case of cgi scripts. Please help me out in executinf these commands.
# 2  
Old 05-29-2011
They're probably not in your PATH. The PATH of CGI scripts are very minimal by default. Either add the relevant directories to your PATH or call the programs by their absolute paths like /path/to/program
# 3  
Old 05-30-2011
Placing a link to the original in your current path is somewhat more secure than modifying the path itself.
# 4  
Old 05-31-2011
Hi,
I tried giving the full path to the swadm utility and executing it. Still it doesnt work. The script runs fine from bash command prompt, but fails in webpage. Can you please advise me how to set the PATH to new lacation? I am using tomcat server

---------- Post updated at 10:46 AM ---------- Previous update was at 07:20 AM ----------

Could the problem be with the user running the script (the user not having permission to run the command) ?? I couldn't run whoami command also from the cgi. Please share your thoughts/info...
# 5  
Old 05-31-2011
Quote:
Originally Posted by jofinjoseph
Hi,
I tried giving the full path to the swadm utility and executing it. Still it doesnt work.
In what way does it "not work"?

Have you tried redirecting stderr somewhere so you can read error messages?
# 6  
Old 06-01-2011
Hi,

Here is the code I am using:

cd /apps/ip06/tibco/iprocess/util
echo `swadm show_processes` > output.txt

"apps/ip06/tibco/iprocess/util" is the location where 'swadm' utility exists. The command works fine in command prompt. but doesnt work as a cgi script, when executed from browser.

It gives no output at all. I get a zero byte 'output.txt' file. I tried writing stderr also. No errors are written.
# 7  
Old 06-01-2011
By full path I don't mean "cd /path/to/application/folder/ ; application". I mean running /path/to/application/folder/appname instead of just appname. This is UNIX, not DOS, being in the same folder doesn't help. It doesn't find things in the current folder by default for security reasons, or anyone could drop a 'swadm' program anywhere and have people run it by accident.

Last edited by Corona688; 06-01-2011 at 12:10 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grabbing fields without using external commands

data: bblah1_blah2_blah3_blah4_blah5 bblahA_blahB_blahC_blahD_blahE im using the following code to grab the field i want: cat data | while IFS='_' read v1 v2 v3 v4 v5; do printf '%s\n' "${v4}"; done im catting data here. in the real world, the exact content of data will be in a variable.... (4 Replies)
Discussion started by: SkySmart
4 Replies

2. Shell Programming and Scripting

scp Commands not executing via cgi script

Hi, I have a CGI script, which includes a python custom header file. The cgi script calls a few functions. Py file. #resourcemanager creation def make_rm(rmip,nip,nport): fp = open("temp1.txt",mode="w") fp.write('<?xml version="1.0"?>\n<!-- Licensed under the Apache... (2 Replies)
Discussion started by: adi.6194
2 Replies

3. UNIX for Dummies Questions & Answers

UNIX commands for a script that I need

Hello. I need help trying to create a script in UNIX to do the following steps. I don't know which commands to input to achieve this. 1. In a directory tree, I want to duplicate all .txt files into the same directory, so 2 of each file exists in each directory where there is a .txt file ... (4 Replies)
Discussion started by: TitanTlaloc
4 Replies

4. Web Development

problem with exporting vairable from one perl cgi to another perl cgi script while redirecting.

Can anyone tell me how to export a variable from one perl CGI script to another perl cgi script when using a redirect. Upon running the login.pl the user is prompted to enter user name and password. Upon entering the correct credentials (admin/admin) the user is redirected to welcome page. My... (3 Replies)
Discussion started by: Arun_Linux
3 Replies

5. Shell Programming and Scripting

Execution problem unix commands in Perl CGI

I am trying to run SSH , mkdir and other unix commands using Perl CGI. But i am not able to Execute these commands. Please help me out !!!! SSH and mkdir is necessity for me. I will be thankful to you...!!!!! I am trying like: In perl CGI file i am writing like: @list = `ssh... (28 Replies)
Discussion started by: Navrattan Bansa
28 Replies

6. Shell Programming and Scripting

[Solved] Value of a variable is not recognised for commands comes from external file

Hi, my script is setting a variable with value and this variable is present in my another command that is coming from external file and this command is internally called after this variable is set. but while execution of this command, the value is not retrieved properly. say, my script... (5 Replies)
Discussion started by: rbalaj16
5 Replies

7. UNIX for Dummies Questions & Answers

Unix commands in perl script

I am totally new to unix commands but I need to understand the following command which is a part of a perl script..what does this mean? myPwd = $(pwd) myTracker = $myPwd/myTracker.out exec > $myTracker 2>&1 (1 Reply)
Discussion started by: athri
1 Replies

8. Shell Programming and Scripting

CGI passing arrays/hashes to another CGI script

If I have a Perl CGI script (script01), which fills an array(s) with information and outputs a HTML page with a link to another CGI page (script02); is there anyway to pass the array(s) from "script01" to "script02" when the page visitor clicks the link? Hope that makes sense! :) (2 Replies)
Discussion started by: WIntellect
2 Replies

9. UNIX for Dummies Questions & Answers

UNIX CGI script

Hey everyone! I hope someone here is good with Unix CGI scripts. I'm having trouble with my CGI. Here's the deal I've created a program that searches the passwd file and cuts the users real name when it's given the login name. When i converted it to CGI i ran into some problems: 1) when you... (3 Replies)
Discussion started by: primal
3 Replies
Login or Register to Ask a Question