Dynamically referencing a Path


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Dynamically referencing a Path
# 1  
Old 05-12-2014
Apple Dynamically referencing a Path

How would I reference a source path (where I have a script pulling data from) that changes location? For example, a Mail folder is being used as a source to pull some data, but somebody could move the folder around in the GUI of Mail, changing it's location in the filesystem (that I am referencing in my script).

Is there a way for my script to follow a change in directory path?

Thanks!
# 2  
Old 05-12-2014
Put the path in a file. Overwrite the file when you update the source path. Read the file when you want to access the Mail folder.
This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 05-13-2014
Use a symbolic link pointing to your target directory, and update it when necessary.
This User Gave Thanks to RudiC For This Post:
# 4  
Old 05-13-2014
Set a shell variable (say MAIL_SRC) to the folder in your .profile or the system wide /etc/profile and update it as needed.

Note this may not work if you have cron jobs that require this $MAIL_SRC variable as cron jobs typically don't run the profile login scripts.
This User Gave Thanks to Chubler_XL For This Post:
# 5  
Old 05-13-2014
They must not move the mail folder (once its set up).
But either way, if they do, the mail client must know where that folder is, thus, that path must be somewhere saved.

Which email client are you using?
Which/where are the config files?

Retrieve that variable from within the script that has been started by the cron job, prior to the other actions of that script.

hth
This User Gave Thanks to sea For This Post:
# 6  
Old 05-13-2014
I am using the Apple Mail on Mac OSX 10.9.2.

It would be REALLY cool if I could replicate the same behavior as an alias, in regard to- if the original folder moves, the alias can still find it without having to update anything. I thought a symbolic link would be the direction to go but I'm not sure.

For simplicity, an example code is below:

Code:
SRC= /Userpath/Library/Mail/Mailboxes/test.mbox

ls -la $SRC

'test.mbox' might get moved to a different directory (within Mailboxes/)

Ideas? I would really like to learn how to automate this path re-direction for this instance as well as future scripts.
# 7  
Old 05-13-2014
If the file cannot e moved outside the Mailboxes directory, but anywhere within it, find should do the trick.
Code:
found=$(find /Userpath/Library/Mail/Mailboxes/ -name *mbox)
echo "Found: $found"

Hope this helps
This User Gave Thanks to sea For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Generate class path dynamically based on source path

Hi experts, I have multiple file names ending with .jsp located in $SOME_DIR, $SOME_DIR/f1/,$SOME_DIR/f2/test,$SOME_DIR/f3/fa and there are equivalent class files in $SOME_DIR/WEB-INF/classes/_pages,$SOME_DIR/WEB-INF/classes/_pages/_f1,... (0 Replies)
Discussion started by: oraclermanpt
0 Replies

2. Shell Programming and Scripting

Referencing file for values and referencing another file to replace values

Hi I have a file which has values in each line: MP304,d40000 MP310,ff0000 etc I have another file which as the first value in it and is unique in the file(not repeated). I need to replace a string with the second value above. The second file contents is as follows:(snippet) <g ... (12 Replies)
Discussion started by: majikins
12 Replies

3. Programming

Symbol referencing errors

Undefined first referenced symbol in file logf /var/tmp//ccwztFsO.o ld: fatal: Symbol referencing errors. No output written to a.out collect2: ld returned 1 exit status float exponC(float mean) { index1++;... (1 Reply)
Discussion started by: willji1234
1 Replies

4. Shell Programming and Scripting

Variable Referencing

I am referencing variables in the following way var1="greeting" greeting="Welcome!" How do I echo var1 in such a way that it outputs Welcome! ? (3 Replies)
Discussion started by: milo7
3 Replies

5. Shell Programming and Scripting

Shell Script Referencing I/O

Is it possible to design a shell script to reference something that queries for input? (This is not to make a script to ssh) For instance if I have a command that when run, it does something like: %<Some command> User's password? Would it be possible to write a script to input something... (1 Reply)
Discussion started by: Prodiga1
1 Replies

6. Shell Programming and Scripting

Back Referencing in SED

Hi, I have tried all examples of back referencing from the web but all in vain. It would be heavily helpful if someone explains me the use of back referencing and sub expression using an example of substitution. Thanks (1 Reply)
Discussion started by: sinpeak
1 Replies

7. Programming

Symbol referencing error

Hey everyone, I can't figure out this symbol referencing error after looking at it for the longest time, and I figured some fresh eyes might be able to point something out I am overlooking. Undefined first referenced symbol in... (1 Reply)
Discussion started by: fromatz
1 Replies

8. Programming

symbol referencing error

Undefined first referenced symbol in file std::basic_ostream<char, std::char_traits<char> >::operator<<(int)/var/tmp//ccTR std::cerr /var/tmp//ccTRcjui.o std::cout /var/tmp//ccTRcjui.o... (1 Reply)
Discussion started by: suhasini
1 Replies

9. Shell Programming and Scripting

Referencing variables in commands

The script I am writing must be able to run several commands (tar, gzip etc) on filenames that are supplied by variables. I am unsure as to what syntax is required/ideal when referencing variables in filenames. The following is a sample command that I would like the script to execute: tar cvf... (3 Replies)
Discussion started by: mharley
3 Replies

10. Shell Programming and Scripting

Referencing a range of parameters?

I can't seem to find anywhere how to syntactically reference a range of parameters in the script I am trying to write. My script requires at least 2 parameters to run, with parameter 1 being the main file, which I want appended to x amount of target files, which will be parameters 2 through... (4 Replies)
Discussion started by: Relykk
4 Replies
Login or Register to Ask a Question