Sponsored Content
Top Forums Web Development Want to edit a sh file using php code Post 302749597 by Corona688 on Friday 28th of December 2012 05:11:48 PM
Old 12-28-2012
It is really not a good idea to run your CGI scripts as root. If someone comprosmises your web server they have won instant access to everything. If someone finds a bug in your program they can exploit it for root access. If your program misbehaves, it can damage anything. There's a reason most things don't run as root, and a reason webservers in particular get very little access to anything -- anyone in the world can cause a request to happen, and can inject any data they want with ease.

You could perhaps use sudo to allow your webserver to run very specific things as root, so you could do system("sudo /path/to/script.sh"); Don't give it a blank cheque. Only let it run very specific scripts, and write those scripts very carefully.
 

9 More Discussions You Might Find Interesting

1. Infrastructure Monitoring

snmp,how to edit code generated by mib2c?

Hi, I'm reading net-snmp site, using C language and unix environment, I have manager ( do get/set command), agent and server ... I'm trying to monitor cpu, memory and disk usage and get Ip address of server and send the value back to agent, stored in variable which enable manager to gets the... (1 Reply)
Discussion started by: zainab
1 Replies

2. Shell Programming and Scripting

Script to Edit the file content and create new file

I have a requirement, which is as follows *. Folder contains list of xmls. Script has to create new xml files by copying the existing one and renaming it by appending "_pre.xml" at the end. *. Each file has multiple <Name>fileName</Name> entry. The script has to find the first occurance of... (1 Reply)
Discussion started by: sudesh.ach
1 Replies

3. Shell Programming and Scripting

Edit a file

I have file like cp -p /var/adm/ /tmp1/tmp1.log cp -p /var/adm/ /tmp1/tmp2.log cp -p /var/adm/ /tmp1/tmp3.log cp -p /var/adm/ /tmp1/tmp4.log I need to re-write the file like: cp -p /var/adm/tmp1.log /tmp1/ cp -p /var/adm/tmp2.log /tmp1/ cp -p /var/adm/tmp3.log /tmp1/ cp -p... (3 Replies)
Discussion started by: h_banka
3 Replies

4. Shell Programming and Scripting

edit file

I have a file containing dates like below 2010 1 02 2010 2 01 2010 3 05 i want the dates to be like below 20100102 20100201 20100305 i tired using awk '{printf "%s%02s%02s",$1,$2,$3}' But it does not work,it puts all the dates in one line,i want them in seperate lines like the... (6 Replies)
Discussion started by: tomjones
6 Replies

5. Shell Programming and Scripting

Script to Check & Edit Content of a file (Addition of comma in each lines of code)

Hi all, I need to write an automated bash shell script which performs such operations: 1. Grep the header of everyline with the initial of "T" in "FILE_A" 2. Perform a for loop, Count the numbers of comma in the line of code, if (no. of comma < 17) ADD the comma until 17; ... (2 Replies)
Discussion started by: big_nutz
2 Replies

6. Shell Programming and Scripting

Best way to edit a file

looking for a script or command to push out from a centralized machine to multiple machines. I have the software in place that will do this already, but I need to tell it what command to run on each machine with this file. what I need is a script or command to edit a file in a specific manner.... (13 Replies)
Discussion started by: skunky
13 Replies

7. Web Development

edit a file with PHP.

Ok here is what I have going on. I am listing the contest of a directory so I can edit and delete files. The code I am using to do that is below (Other then editing as it does not work). <?php $directory = ("enctlfiles/"); $dir = opendir($directory); $files = array(); while (($file =... (10 Replies)
Discussion started by: GroveTuckey
10 Replies

8. Programming

Are there any C code r instruction to see where is the creation or last edit for the file

Are there any C or termina instructin code or instruction to see where is the creation or last edit for the file (1 Reply)
Discussion started by: fwrlfo
1 Replies

9. Programming

C++ Edit code

Hi guys, I am learning C++ on my own and i wanna redit the code using classes and heritance to revamp the code below. example class for the card attributes -suit , - rank, - face and also class deck to contain shuffle and a class player with the function to setcard and a function handonecard... (1 Reply)
Discussion started by: ment0smintz
1 Replies
UPSSET.CGI(8)							    NUT Manual							     UPSSET.CGI(8)

NAME
upsset.cgi - Web-based UPS administration program SYNOPSIS
upsset.cgi Note As a CGI program, this should be invoked through your web server. If you run it from the command line, it will sit there until you give it input resembling a POST request. DESCRIPTION
upsset.cgi lets you access many administrative functions within the UPS software from your web browser. You can change settings and invoke instant commands where available. CHANGING SETTINGS
Some UPS hardware allows you to change certain variables to other values. To see what's available, pick a UPS from the chooser and select "settings", then select "View" to update the page. You should see a list of items with the descriptions on the left side and the possible options or input spaces on the right. After changing something, be sure to "Save changes" to update the values in your UPS. If your UPS doesn't support any read/write variables, there will be nothing to do on this page. Setting values in read/write variables can also be done from the command line with upsrw(8). INSTANT COMMANDS
Some UPS hardware also has provisions for performing certain actions at the user's command. These include battery tests, battery calibration, front panel tests (beep!) and more. To access this section, do as above, but pick "Commands" as the function. If your UPS supports any instant commands, they will be listed in a chooser widget. Pick the one you like and "Issue command" to make it happen. Note some dangerous commands like "Turn off load" may not happen right away. This is a feature, not a bug. The apcsmart driver and some others require that you send this command twice within a short window in order to make it happen. This is to keep you from accidentally killing your systems by picking the wrong one. To actually turn off the load, you have to send the command once, then send it again after 3 seconds elapse but before 15 seconds pass. If you do it too quickly or slowly, you have to wait at least 3 seconds but not 15 seconds again. You can also invoke instant commands from the command line with upscmd(8). ACCESS CONTROL
upsset will only talk to upsd(8) servers that have been defined in your hosts.conf(8). If it complains about "Access to that host is not authorized", check your hosts.conf first. SECURITY
upsset will not run until you convince it that your CGI directory has been secured. This is due to the possibility of someone using upsset to try password combinations against your upsd(8) server. See the example upsset.conf file for more information on how you do this. The short explanation is--if you can't lock it down, don't try to run it. FILES
hosts.conf(5), upsset.conf(5) SEE ALSO
Internet resources: The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ Network UPS Tools 05/22/2012 UPSSET.CGI(8)
All times are GMT -4. The time now is 01:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy