From: Luckystr Luckystr Date: 2009-08-18T05:46:54+09:00 Subject: Re: Can't execute shell commands in CGI 7stud -- wrote: > Luckystr Luckystr wrote: >> It is necessary to execute linux command in CGI(apache) >> [code]def cmd(com) >> system("#{com}>log.log") >> end >> cmd("pwd")[/code] >> There isn't errors but log.log is empty >> Else: >> [code]def cmd >> system("pwd>log.log") >> end >> cmd[/code] >> there isn't result too. > > 1) There aren't any code tags here. You can just post your code and the > indenting will be preserved. > > 2) Where is log.log located in your Apache directory structure? The > correct path to that file needs to be specified in your cgi script. > > 3) Check your apache error logs located here: > > /logs/error_log > > and see what the last few lines say. It may say something like: > > log.log: Permission denied > > In that case, you'll need to change the permissions for log.log to give > 'others' write privileges, so that your script can write to log.log, > something like this: > > $ sudo chmod o+w /full/path/to/log.log errorlog: sh: log.log: Permission denied The path log.log can be correct since ">" creates a file if it does not exist. But just in case, I checked path in script make access pattern 0777. Outgoing from logfile, I think that there is error because user "apache" doesn't have shell. I tried to make apache's shell by "adduser" by "root" but linux said that it's impossible. -- Posted via http://www.ruby-forum.com/.