I use postfix and procmail for mail and folder filtering. I have a main address and a bunch of alias addresses that go to it, then I sort the username to a folder that matches. For example I have the main address of 'address#domain.com" and a alias of "customer1#domain.com" pointing to it, and I have a folder called 'customer1' under 'address#domain.com' and a script like the following in .procmailrc -
:0:
* ^(To|Cc).*customer1#domain.com
.customer1/
and it works fine, but every time I add a alias I have to also add a line in .procmailrc to filter to it. Would there be a way I can create the alias, the folder, and have one procmail recipe that would grab the 'customer1' from the address and store the message in a folder by that same name? Even having procmail create the folder if it does not exist would be great too. Thanks!
Ok I found another question that was similar that solved this,
Procmail to automatically make new folders to store emails from new senders
So the following code solved the quesiton -
Who=`formail -zxTo: | cut -d# -f1`
:0
* ? mkdir -p ".$Who"
.$Who/
I tested it and it worked wonderfully
Related
In opencart version 3 there is a notification:
It is very imporant that you move the storage directory outside of the
web directory (e.g. public_html, www or htdocs)
Screenshot
I tried by clicking on move button in the picture also tried manually but after trying it is giving weird errors.
You can move storage directory outside of the web directory (e.g. public_html, www or htdocs) in three ways
Automatically Moving
Manual Moving (from admin panel)
Manual Moving ( By editing Config files)...
Assuming that you know first and second methods.Here I will explain the third method to you.
Copy your storage directory from system/storage to public_html, www or htdocs.
Change the following file path from both config files i.e. config.php and admin/config.php as shown below.
define('DIR_STORAGE', 'public_html/storage');
Please replace public_html to your desired path.
I hope this answer might help you.
It is very simple to remove / hide this dialog box:
open 'admin/controller/common/dashboard.php' file
search below line
$data['security'] = $this->load->controller('common/security');
and replace it with below line
$data['security'] = '';
That's it :)
Change directory path as decribed abowe--but when You save the config.php use utf8 encoding. I have worked 2 hour on it- did everithing i found on google, but nothing worked. Just this simple thing!
I also ran into this little problem, and the fault was layer 8 (problems between the keyboard and the chair)
I hadn't read the code that I had to change correctly and I was doing it wrong, I'll explain better in case someone runs into the same problem:
capturing the variable to be deleted
I was just replacing the new directory path, not removing the DIR_SYSTEM variable.
you have to delete DIR_SYSTEM and place the new route. that's all.
For this reason it gave me an error and so I came to this post.
It is my first contribution. I hope this helps you.
I have one problem about filezilla. I accidentally move one folder to wrong directory, so it shows the errors when I view my website.
How can I solve it? Please help me.
Many thanks in advance for your answer.
You cannot undo, but you should understand why that happened and how to prevent that from happening again in the future.
This happened because Filezilla allows Drag-and-drop move functionality on both folders (directories) and files, very dangerous on production servers.
There is actually a feature-request for 11 years now, please add your vote to the list to get this done: https://trac.filezilla-project.org/ticket/2191
In the mean time, please consider using another software that allows the user to set this behavior as an option:
WinSCP: http://winscp.net/eng/docs/screenshots
WS-FTP Pro: https://trac.filezilla-project.org/attachment/ticket/2191/ws_ftp-professional-options.gif
EDIT: Filezilla team responded (sort of) to the feature request and you can block drag and drop in the xml config file. It's better than nothing.
You cannot undo ftp moves. The only way to rectify the problem is to manually move the folder to it's original location.
I suggest you be more careful from next time.
If you don't know where the folder belongs, download the x-cart script package and check where the directory belongs.
Sorry for late, but I am up to date. I get logs from filezilla of moved files.
Status: Renaming '/var/www/html/brb/abc.js' to '/var/www/html/brb/node_modules/abc.js'
Status: /var/www/html/brb/abc.js -> /var/www/html/brb/node_modules/abc.js
Status: Renaming '/var/www/html/brb/xyz.html' to '/var/www/html/brb/node_modules/xyz.html'
Status: /var/www/html/brb/xyz.html -> /var/www/html/brb/node_modules/xyz.html
I write script in js to build command
let x = ['/var/www/html/brb/abc.js -> /var/www/html/brb/node_modules/abc.js',
'/var/www/html/brb/xyz.html -> /var/www/html/brb/node_modules/xyz.html'];
let cmd = [];
x.forEach(p => {
let path = p.split('->');
cmd.push(`mv ${path[1]} ${path[0]}`);
})
console.log(cmd);
Output:
['mv /var/www/html/brb/node_modules/abc.js /var/www/html/brb/abc.js'
'mv /var/www/html/brb/node_modules/xyz.html /var/www/html/brb/xyz.html']
Use any editor like vscode etc and remove string quotes and execute command in server terminal etc
mv /var/www/html/brb/node_modules/abc.js /var/www/html/brb/abc.js
mv /var/www/html/brb/node_modules/xyz.html /var/www/html/brb/xyz.html
A simple answer is,
Copy the folder into the desired location and then delete from the current location where you moved it mistakenly.
Now, what if you overwrite a file.
I just edited a file in local, then downloaded the file from my server into the local, and my all the local updated data is gone. There seems no solution of this, but there may be one possibility, I may be the lucky enough that this is my case.
If you were working on that local file, so most probably it is opened in your browser. Do not refresh it. Copy the content one by one, and update the file again. You can also open developers tools of both old and new page. Compare them line by line and do the job.
I had the same issue and resolved it manually.
The log panel was helpful in this. It is the large panel below the connection form in the top menu.
From that log panel, I was able to figure out all the files which were moved with their current and previous location.
I copied those all log lines and paste them somewhere in notepad and then manually selected all files and move those all at once to their original directory.
Screenshot: The log panel showing last actions
Disclaimer: This is homework; I don't want a solution.
Also, no libraries outside c/c++ standard libraries are available.
I'm looking for a push in the right direction to understand what this portion of work from my assigned semester project (create a virtual FTP server) is even asking me to do:
The server allows to create a virtual filesystem. By a virtual filesystem, we mean a mapping of a served directory to the real directory on the filesystem. For example, the client tree will look like: /home/user1 maps to /mnt/x/home/user1 /www maps to /var/cache/www /home/user_list.txt maps to /var/ftpclient/user_list.txt The user will see /home/user1 directory and /www directory and the file /home/user_list.txt
I followed up with this question to my lecturer:
Are /home/user1 -> /mnt/x/home/user1 , /www -> /var/cache/www , and /var/cache/www/home/user_list.txt -> /var/ftpclient/user_list.txt the only directory mappings which need to be supported (so each user will have 2 directories and 1 file as shown automatically created for them)?
to which the following reply was given:
These mappings are just example settings. Your solution should be able
map anything to anything it similar way.
From my current understanding, I need to only allow users of my FTP server to access directories and files which are explicitly mapped (specified via the configuration file). This will probably mean a mapping of something like /home -> /home/users (so all users will see that they're in a pseudo root directory for FTP-ing stuff, e.g. user Bob sees /home/bob/.
Also, with which API do I need to work to support FTP commands like ls, cd, etc. which work with the real unerlying file system?
You are creating your own FTP server (or at least a portion thereof). It will need to solve the problem of /home/bob translates to /home/users/bob. I believe the way you are meant to do this is that if someone types cd /home/bob, you simply translate the passed in file-location to a function that takes the user-provided pat (in this case/home/bob) to it's "real" form (/home/users/bob) before it's passed to the chdir function that actually changes the directory. To make things like pwd and ls show the correct path, you will either need to "remember where you are" (bearing in mind that someone may want to do cd ../joe, cd ../tom/.././mats/../joe, or cd ..; cd joe to move to /home/joe, which should all [modulo my typos] translate to /home/users/joe but display as /home/joe - in other words, your cd will need to understand the current directory . and parent directory .. to move around), or have a "reverse translation" that takes /home/users/joe and comes up with /home/joe. It's my current thought that the latter is simpler, but I haven't solved EXACTLY this problem.
There are probably several solutions that you can follow, but a "match start of string" and working in absolute paths would work unless you want to do very complicated things and allow you don't need users to do REALLY complicated things, for example, if we have this mapping:
/home -> /mnt/x/home (e.g /home/bob becomes /mnt/x/home/bob)
/www -> /var/cache/www (e.g /www/index.html becomes /var/cache/www/index.html)
Now, if a user were to do:
cd /home/bob/../../www/ (could be worse with more . and .. mixed in)
then you need to actually understand where you are, and translate fix up ../.. into / again. [Of course, similar problems using a cd /home/bob then cd .. and cd www may pose similar problems].
I would clarify if that is actually required by your lecturer.
If it is not required, then match the start of anything starting with / (everything else, just pass to chdir without change)
The last question is the easiest: use the Boost Filesystem library, it has the types you'll need such as file paths.
For the first question, the idea is that GET /home/user_list.txt returns the contents of /var/ftpclient/user_list.txt. That means you first need to translate the virtual name into a real name (Some fanciness is possible here, but basically you want to check if any prefix of the virtual name appears in the translation table. Fanciness includes dealing with the case of names not found). Secondly, with the real name you want to open that file, read its contents, and return those to the client.
I am working on a script that duplicates folders from an afp share to a local folder and does all kind of things with those folders afterwards. (it deletes the original folders after duplicating)
This code is working fine:
tell application "Finder"
duplicate every folder of folder afpFolder to localFolder with replacing
delete every folder of folder afpFolder
end tell
My problem is that our employees will be adding new folders to afpFolder regulary and quite often. My script is running every 10 seconds (with LaunchAgents) because it needs to process the duplicated data as often as possible.
The question I have is: What happens when the script is duplicating and deleting folders and in the exact same moment somebody adds a new folder to afpFolder?
Does the script only delete what was in afpFolder in the moment it started running or could it be that it would delete one of those newly created folders without duplicating it?
I have also thought about making something with a list. For example:
set folderList to {}
tell application "Finder" to set folderList to every folder of afpFolder
duplicate folderList to localFolder
delete folderList
(this might not work this way)
Can anyone please help me answer the question?
Can I work with the upper code where I just duplicate and delete? Or do I have to worry about the script deleting folders that are created in the moment the script runs, without duplicating them?
If the upper code can cause trouble, can you help me with the list solution?
The first script would delete items that are added between the duplicate and delete commands. But I can't think of any case where the second approach would not work:
tell application "Finder"
set l to items of ((POSIX file "/private/tmp/test") as alias)
duplicate l to desktop
delete l
end tell
You could also try using mv or rsync:
do shell script "mv /path/to/afp_folder/* /path/to/local_folder/"
do shell script "rsync -a /path/to/afp_folder/ /path/to/local_folder/
rm -r /path/to/afp_folder/*"
The code from your answer #John Alarik is inefficient and I think in some spots it won't even work. Please don't take that as a criticism because I can see you're trying hard to find a solution which is the right way to go about getting help. So I thought I'd help with your code.
First you seem to be doing many unnecessary conversions of strings, alias's, and file specifications. In addition some of them are incorrect in the context you are using them and will probably cause errors. Your repeat statement in overly complicated too.
Try this code. It works in the same manner as you want but is much cleaner and shouldn't have any errors. I hope it helps. Good luck.
set afpFolder to "examplepath:path:folder:" as alias
set localFolder to "examplepath:path:folder:" as alias
tell application "Finder"
set folderList to folders of afpFolder
repeat with aFolder in folderList
duplicate aFolder to localFolder with replacing
delete aFolder
end repeat
end tell
Don't make it more complicated than it needs to be.
Both Duplicate and Delete can accept a list as a direct parameter. There is no need for any repeat loops. Please note that this is the same format that Lauri suggested, just formatted with the OP's example. Give her the upvote.
set afpFolder to "examplepath:path:folder:" as alias
set localFolder to "examplepath:path:folder:" as alias
tell application "Finder"
set folderList to folders of afpFolder
duplicate folderList to localFolder
delete folderList
end tell
Update: See #regulus6633's post about this code!
Thanks for all the help. In the meantime I could solve my problem even without your answers due to a good code snippet I found for making and processing a list.
This is the final solution, which works fine even if you copy a new folder to afpFolder while the script is running.
tell application "Finder"
set afpFolder to "examplepath:path:folder:" as alias
set localFolder to "examplepath:path:folder:" as string
set folderList to every folder of folder afpFolder
set i to 1
repeat the count of folderList times
set afpUniqueFolder to (item i of folderList) as string
duplicate afpUniqueFolder to localFolder
delete afpUniqueFolder
set i to i + 1
end repeat
end tell
I know that there is also a command called move instead of duplicate and delete.
We had some strange issues with move before, so since then I stick to duplicate and delete.
Thanks to all! This website is very helpful!
I've been trying to solve this for weeks...
My Goal is to search my inbox for the following messages:
Hello
Hi
Hey
Im using three files to do this for me. The first, a .forward file in my $HOME
"|IFS=' '&&exec usr/bin/procmail||exit 75 #username"
And these two are in my ~/.procmail directory
.procmailrc
VERBOSE=off
MAILDIR=$HOME/Mail
PMDIR=$HOME/.procmail
DEFAULT=/var/spool/mail/username
LOGFILE=$PMDIR/log
INCLUDERC=$PMDIR/general.rc
#end of .procmailrc
And lastly the rule file: general.rc
:0
* ^From:.*sumone#sumaddy.com
* ^Subject:.*hello
$HOME/Mail/Hello
What's supposed to happen is that all three of these files work together to copy and move mail that contain the hello pattern in its subject. And to be safe it will also look for a certain persons address. Then when those patterns are matched it will stick what it found and create the specified path; if it doesn't already exist.
But its not doing that.
After I'm done editing these files in emacs, vi, .. and then save it, will it work automatically? Or do I need to compile it?
If I do, the .procmailrc might require ( if not all ) the 'Shell=/bin/sh'
Not that I didn't try that...
No, my poorly developed design is to process incoming mail..
I've tested it, by sending emails to myself.
What i think, is that my General.RC file isnt coded write. Because, directly after i send myself an email, it SHOULD copy and move it to the specified directory.
Its no wonder that i've made those mistakes, i've edited all three of these files a milllllion times.
Nothing is displayed in my LOG file...
I've fixed everything else and i know my /usr/bin/procmail exists because i used whereis to see its path.
But my testing still fails. I keep sending myself emails and checking my Mail Folder to see if the bytes in my "Hello" file have increased..
How can i get the log to work?
Is the general.rc wrong?
Procmail processes mail as it comes in, not when it's just sitting there in your mailbox. If you want to process mail that's already in your mailbox, you've got to pass it through procmail again, either by "bouncing" it to yourself, or by piping it through procmail. In a command line email client like mutt, you'd do the former with the 'b' command, and the latter by typing |procmail
If you wish to process email you already have, you will need to:
Exit any mail clients
Move away your current Inbox (mv /var/spool/mail/username /tmp/mail.username )
formail +1 -ds procmail < /tmp/mail.username
Your ~.forward file has a missing '/' before usr. Also, you may keep it short like this;
"| **/**usr/bin/procmail"
put your .procmailrc under your HOME directory
After setting your MAILDIR, write only "Hello" as the mailbox name in general.rc. Also use ":0:" at the beginning of the recipe to enable locking, all deliveries must lock the mailbox file!
Make sure you have procmail installed at /usr/bin/procmail on the server.
Make sure "Hello" file exists in your MAILDIR.
Check the log file
If all you want is to find messages on your disk with one of those Subject lines, I would recommend fgrep on your inbox.
I think your primary concern before any other debugging is to verify that procmail is being run on your incoming e-mail messages.
My suggestion is to make your .procmailrc file look like this (with nothing else)
VERBOSE=on
LOGFILE=/tmp/procmail.log
:0 fhbw
| sed "s/^Subject:/& --procmail working--/"
Then send yourself an e-mail message.
You should get a logfile in /tmp/procmail.log and your e-mail message should arrive in your mailbox with the subject line modified to include "--procmail working--".
If that doesn't work, then procmail is not being called and you should edit your question to show the current contents of your .forward file.
If that works, then the problem is with the contents of your .procmailrc or your general.rc file. You should edit your question to show the current contents of those two files.