The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Microsoft Security Advisory (953818): Blended Threat from Combined Attack Using Apple iBot Security Advisories (RSS) - Microsoft 0 06-02-2008 08:30 PM
combined stdout & stderr slavam UNIX for Advanced & Expert Users 11 10-12-2007 04:06 PM
grep command with combined variables in Ksh cin2000 Shell Programming and Scripting 4 02-22-2006 10:57 AM
help on find with chmod.. urgent help needed sdlayeeq UNIX for Advanced & Expert Users 4 03-29-2005 12:05 AM
chmod 777 on all directories below...how do I do that using the "find" command? Neko UNIX for Dummies Questions & Answers 7 07-12-2001 10:58 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-17-2007
smoother smoother is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 17
FIND/CHMOD combined

I am trying to change permission for all subdirectories and files inside folder1 so this is what i came with after many seraches on the internet. man find and man chmod mirc and few articles.

Code:
find .public_html/folder1 -print0 | xargs -0 chmod 777
what's wrong with this command?
it is FTP Server btw, if it means something at all

Thanks

<edit>
Ah i nearly forgot to say that i also tried with recursive method of the CHMOD command:
Code:
chmod -R 777 public_html/folder1
Am i missing some sign to the start something at the end maybe?
Thanks ones again

Last edited by smoother; 09-17-2007 at 03:18 AM.. Reason: more info about the problem
  #2 (permalink)  
Old 09-17-2007
smoother smoother is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 17
What is most important sending a command for a single file/dir works flawless:
Code:
chmod 755 folder1/index.html
Why i just cannot execute the same command in a recursive flavour ?
  #3 (permalink)  
Old 09-17-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Probably because it can't treat files and directories the same?

Try "find ... -print -type f | xargs -n 1 chmod 777"

the "xargs -n 1 ...." means do a command per argument
the "find ... -type f" means only print files
  #4 (permalink)  
Old 09-17-2007
smoother smoother is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 17
Nothing happens:

Code:
find /public_html/* -print -type f | xargs -n 1 chmod 755
no errors but also not affected files

Maybe i am doing something wrong with the slashes? please check that code ones again. Thanks a lot
  #5 (permalink)  
Old 09-17-2007
ajcannon ajcannon is offline
Registered User
  
 

Join Date: Aug 2007
Location: Binfield, Berkshire. UK
Posts: 91
chmod

Not promising anything but try

find <dir> -type f -exec chmod 777 {} \;

I believe that to change the permissions on a file you have to be the owner or root
  #6 (permalink)  
Old 09-17-2007
smoother smoother is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 17
Nope ! the same result. Nothing happens

Maybe i should mention that i am executing this command from C# code.
Actually i am trying to send this command from C# FTP Client and please notice that it works flawless if i target only single file or directory. I just cannot make it to works for all files and dirs inside the selected directory. in a recursive manner.

For example this is the code that change permissions for index.html file:

Code:
TcpClient tcpClient = new TcpClient();
tcpClient.Connect(this.txtServerAddress.Text, Convert.ToInt32(this.txtPortNumber.Text));
NetworkStream netStream = tcpClient.GetStream();
System.IO.StreamReader strReader = new System.IO.StreamReader(netStream);

byte[] WriteBuffer = new byte[1024];

//passing ASCII characters 
ASCIIEncoding enc = new System.Text.ASCIIEncoding();

// Pass the username to the server
WriteBuffer = enc.GetBytes("USER " + "username" + "\r\n");
netStream.Write(WriteBuffer, 0, WriteBuffer.Length);
// Read the server response line from the stream reader
MessageBox.Show(strReader.ReadLine());

// Pass the password to the server
WriteBuffer = enc.GetBytes("PASS " + "password" + "\r\n");
netStream.Write(WriteBuffer, 0, WriteBuffer.Length);
// Read the server response line from the stream reader
MessageBox.Show(strReader.ReadLine());

//CHANGE PERM. OF INDEX.HTML
WriteBuffer = enc.GetBytes("CHMOD 775 " + "public_html/index.html" + "\r\n");
netStream.Write(WriteBuffer, 0, WriteBuffer.Length);
// Read the server response line from the stream reader 
MessageBox.Show(strReader.ReadLine());

tcpClient.Close();
As i said this code works like a charm changing permission of index.html

Thanks for any further help
Closed Thread

Bookmarks

Tags
chmod, find, finding files, xargs

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0