LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-12-2024, 12:41 PM   #1
mike1950r
LQ Newbie
 
Registered: Oct 2021
Posts: 24

Rep: Reputation: Disabled
Chmod command in procmailrc


Hi,

is it possible to use a chmod command in procmailrc file?
I need to set a file permission if a certain matches,
and set another permission afterwards.

Thanks for a tip.

Cheers mike
 
Old 04-12-2024, 01:15 PM   #2
metaed
Member
 
Registered: Apr 2022
Location: US
Distribution: Slackware64 15.0
Posts: 365

Rep: Reputation: 171Reputation: 171
Quote:
Originally Posted by mike1950r View Post
is it possible to use a chmod command in procmailrc file?
Yes. Take a look at the example in man 5 procmailex that begins "Store all the messages about meetings in a folder that is in a directory that changes every month."

In that example, an arbitrary shell command is executed (mkdir $MONTHFOLDER) in the first rule, and the actual message disposition is in the second rule. You could instead supply the suitable chmod command line.
 
Old 04-12-2024, 02:39 PM   #3
mike1950r
LQ Newbie
 
Registered: Oct 2021
Posts: 24

Original Poster
Rep: Reputation: Disabled
Hello,

thanks for this tip.
Still got a problem:

Code:
:0 Wic
* ? test ! -d /var/mail/test
| 'chmod 662 /var/mail'
Code:
procmail: Executing "chmod 662 /var/mail"
/bin/sh: 0: Can't open chmod 662 /var/mail
procmail: Non-zero exitcode (127) from "chmod 662 /var/mail"
cheers mike
 
Old 04-12-2024, 03:12 PM   #4
metaed
Member
 
Registered: Apr 2022
Location: US
Distribution: Slackware64 15.0
Posts: 365

Rep: Reputation: 171Reputation: 171
Quote:
Originally Posted by mike1950r View Post
Code:
:0 Wic
* ? test ! -d /var/mail/test
| 'chmod 662 /var/mail'
Code:
procmail: Executing "chmod 662 /var/mail"
/bin/sh: 0: Can't open chmod 662 /var/mail
procmail: Non-zero exitcode (127) from "chmod 662 /var/mail"
Normally the shell breaks down a command line into words, by looking for spaces. The first word identifies the utility command to be called, and the remaining words are passed to it as arguments:
[0] = chmod
[1] = 662
[2] = /var/mail
Trouble is, your single quotes are escaping all the spaces, so the first word is the entire line:
[0] = chmod 662 /var/mail
The error message is trying to tell you there is no utility command with that name.
 
Old 04-12-2024, 03:55 PM   #5
mike1950r
LQ Newbie
 
Registered: Oct 2021
Posts: 24

Original Poster
Rep: Reputation: Disabled
If I use double quotes I get same error message. ("chmod 662 /var/mail")
Without quotes it does not work either.
What shall I use instead?

Cheers mike
 
  


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
Apache: difference between chmod 644 and chmod 666 and chmod 600 for output/txt/dat? frenchn00b Programming 6 04-22-2009 01:10 PM
What can we do if we type chmod ugo-x /bin/chmod ?????? bunny123 Linux - Software 3 02-01-2005 08:53 PM
CHMOD in shell : chmod 777 /usr/ <---is that right? cpanelskindepot Programming 5 07-16-2004 05:37 AM
chmod +s or chmod -s excel28 Linux - General 1 09-30-2003 03:55 AM
Calling chmod from a procmailrc J_Szucs Programming 1 02-16-2003 01:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:05 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