LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-08-2008, 02:10 PM   #1
aliahsan81
LQ Newbie
 
Registered: Sep 2008
Posts: 22

Rep: Reputation: 0
Question need help urgent


I am new to bash scripting,I am writing a script to find world writeable directories.and in that directoires i want to find some specific file type like php.cgi.and few more,I am using the following command to do the this job,But when i have there world writeable directories,i am unable to find these file type,plz suggest and give some code for help aslo thx

find /var/www/html/ -type d -perm 777 -print

Result

var/www/html/test/test1
/var/www/html/phpBB3/cache
/var/www/html/phpBB3/files
/var/www/html/phpBB3/images/avatars/upload
/var/www/html/phpBB3/store
 
Old 09-08-2008, 02:12 PM   #2
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Doesn't sound particularly urgent to me.

Unless, of course, you didn't get around to doing your homework over the weekend and now you have to hand it in soon?
 
Old 09-08-2008, 02:20 PM   #3
aliahsan81
LQ Newbie
 
Registered: Sep 2008
Posts: 22

Original Poster
Rep: Reputation: 0
I have worked over they weekend but didnt find any thing.I am realy try hard but not luck.
 
Old 09-08-2008, 02:36 PM   #4
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Then what you need to do is present the code you have constructed, thus showing what you have done, and ask what is wrong with it or how it might be improved.

You do this to show people here that you ARE putting in the effort and just haven't figured something out. You do that and someone is probably going to step forward and help you.

When you simply say (as you have) that you want someone to do your homework for you, no one at all will lift a finger.

edit: In the find statement you provided, you specified that you were looking for directories. Directories are what you are getting. What else would you expect?

Last edited by jiml8; 09-08-2008 at 02:38 PM.
 
Old 09-08-2008, 02:36 PM   #5
CRC123
Member
 
Registered: Aug 2008
Distribution: opensuse, RHEL
Posts: 374
Blog Entries: 1

Rep: Reputation: 32
LOL, piece it together:

You've got the directories you need, now all you need to do is get the contents of the directories('ls') and grep for what you're looking for.

p.s. Working all weekend should have gotten you much further than this. Have you read your textbook? Lots of times teachers will draw on examples from textbooks to formulate their questions.

edit: after seing jiml8's post, i second that

Last edited by CRC123; 09-08-2008 at 02:38 PM.
 
Old 09-08-2008, 02:39 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by aliahsan81 View Post
I have worked over they weekend but didnt find any thing.I am realy try hard but not luck.
What have you tried? What errors have you gotten?

This does seem alot like homework to me, too. Try to Google for a solution....I found a three scripts and numerous commands on the first page of results alone.
 
Old 09-08-2008, 02:46 PM   #7
aliahsan81
LQ Newbie
 
Registered: Sep 2008
Posts: 22

Original Poster
Rep: Reputation: 0
Thx TB0ne this not home work i have similar script in php but my boss want in bash,and i am not sound in bash,i have problem that when find command return result i store in a variable,but there are many dir in that variable i dont seem to got any idea how to process each dir to find file that have extension like php cgi etc.
 
Old 09-08-2008, 02:52 PM   #8
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Well, guys, have fun. You can answer him if you wish, but I'll point out that my first post said "homework" and his response implicitly agreed because he had worked hard on it over the weekend. But now it is something for his job and his boss wants it in bash rather than php.

And he still has not provided code samples other than the find statement. The PHP code could provide all kinds of valuable clues. LOL.

You can believe him if you want to; I certainly don't believe him.

Hasta la bye-bye to this thread.
 
Old 09-08-2008, 03:27 PM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by aliahsan81 View Post
Thx TB0ne this not home work i have similar script in php but my boss want in bash,and i am not sound in bash,i have problem that when find command return result i store in a variable,but there are many dir in that variable i dont seem to got any idea how to process each dir to find file that have extension like php cgi etc.
Re-read my first post. If you google for this, you'll find lots of results. If this is for your work, you can tell your boss you don't know bash, and they'll give it to someone else, or give you time to work on it.

As before, we've asked to see what YOU'VE ALREADY DONE, and you haven't provided it. Go look up the answer, or find one of the thousands of bash tutorials that are available on the web. If you're an experienced PHP programmer, you shouldn't have problems with a very simple task in a scripting language.
 
Old 09-08-2008, 03:42 PM   #10
aliahsan81
LQ Newbie
 
Registered: Sep 2008
Posts: 22

Original Poster
Rep: Reputation: 0
thx TB0ne find very usefull thing like i tell u and i have time to make this script,time dont matter but,let me tell you what i have find,But i must say people in this forum are not professionals,expect you.thx any way to all.

find /var/www/html -type d -perm 777 -print -exec ls -la {} \; | grep -i .php

/var/www/html/phpBB3/cache
-rw-rw-rw- 1 apache apache 773 2008-08-22 00:14 ctpl_admin_install_footer.html.php
-rw-rw-rw- 1 apache apache 4591 2008-08-22 00:14 ctpl_admin_install_header.html.php
-rw-rw-rw- 1 apache apache 4304 2008-08-22 00:14 ctpl_admin_install_install.html.php
-rw-rw-rw- 1 apache apache 285 2008-08-29 17:58 ctpl_admin_install_main.html.php
-rw-rw-rw- 1 apache apache 103 2008-08-22 00:14 data_hooks.php
/var/www/html/phpBB3/files
/var/www/html/phpBB3/images/avatars/upload
/var/www/html/phpBB3/store


and this how it look before

#!/bin/bash


Docroot[0]="/var/www/html/"

export IFS=$'\n'

# Loop through our array.
for x in ${Docroot[@]}
do
# Find all directories & subdirectories
for i in $(find $x -type d -perm 777 )
do

echo $i

done

# Find all Files
for i in $(find $x -type f -perm 777 -name "*.php")
do

echo $i
done
done
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
boot sector and lilo collapse !!!!! URGENT URGENT URGEN !!!!! frelihm Linux - Software 21 12-02-2009 10:21 AM
how to mv the files...urgent...urgent manojkarthi Programming 2 07-02-2008 02:21 AM
Urgent Question Regarding Urgent Questions! Need Help Now! Crashed_Again LQ Suggestions & Feedback 11 10-17-2007 08:07 PM
Urgent Urgent !!!! Mozilla Keeps All Your Deleted Emails !!!! odin123 Linux - Software 2 01-31-2004 02:22 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration