Check mail periodically with tcsh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check mail periodically with tcsh
# 1  
Old 05-26-2010
Check mail periodically with tcsh

A friend of mine is switching his email from one University server to a different one. He is using the tcsh, and on his current server, the shell will tell him (when the prompt is displayed) if there is new mail. The new server, where he also has the tcsh, does not do this by default. I got him to do this:

Code:
alias precmd "if ( -e $MAIL ) if ( ! ( -z $MAIL ) ) echo You have mail."

where $MAIL expands to /var/mail/my-friends-login-name

He poked around, and that is indeed where his mail is stored. The alias is in his .aliases file. It (the alias) seems to be working, but there is a problem. The string "You have mail." is getting echoed every time the prompt is printed, as if he had new mail all the time, except that he doesn't. So I guess the if statement I told him to use is not correct. I am by no means a tcsh guy, so I am not sure of what I am missing here.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check mail queue

We use Redhat server , we always use mailq to check any pending mail in mailq , when run the command mailq , it shows all existing pending mail would advise how to write a script to show the pending mails which are older than 24 hours , ( if possible , then send this pending mail info to... (9 Replies)
Discussion started by: ust3
9 Replies

2. Shell Programming and Scripting

Check pending mail in mail queue

I know the command mailq can check the pending mail in mqueue , and also have another command to check POSIX mail queue in server , now I will regularly check the mqueue manually , it is time consuming , would advise the script that could help to check the mail queue , and then send the details to... (3 Replies)
Discussion started by: ust3
3 Replies

3. Shell Programming and Scripting

Csh/tcsh : Check the file existance and run the script

Hi, I've to wait until a file generated and once its generated, source another script in Linux terminal. Please help me as this is very very urgent. The code should be something like if ( -e "/abc/xyz/a.txt ) source aaa.csh else sleep This should be repeated till the if... (4 Replies)
Discussion started by: kumar_eee
4 Replies

4. Solaris

UFS File System Periodically Corrupted - What to check?

The system is a SunFire V440 running SunOS 5.10 About once every 3-4 weeks, the system will reboot into single user mode on its own, and then I run svcs -xv, the filesystem service and dependent services will be disabled due to the metadisk file system being corrupted. The I've been doing... (2 Replies)
Discussion started by: the.gooch
2 Replies

5. UNIX for Advanced & Expert Users

mail attachment limit check

I want to check the mail attachement size before sending the mail. I coded: IF FILESIZE > XBYTES THEN MESSAGE "Mail attachment size exceeds limit" ELSE SEND MAIL. But I want to know the quantifier. To get the XBYTES, I used ls -ltr filename | awk '{print $5}' into a variable, now,... (1 Reply)
Discussion started by: harishkumardola
1 Replies

6. Shell Programming and Scripting

TCSH Check if number is even

Hey, I am trying to check if an integer is even in a tcsh script This is what I am running now set lattest = ` echo $latmin "%2" | bc -l ` echo $lattest if ( $lattest == 0 ) then echo "min is already even" else if ( $lattest =! 0 ) then set latmin = ` echo $latmin "+1" |... (2 Replies)
Discussion started by: travish12
2 Replies

7. Shell Programming and Scripting

How to check the mail permissions

Hi - I am trying to send email from unix box but none were delivered. I have tried multiple commands like mailx, mail or sendmail. But none of them worked. can you please let me know how to check if I have the right permissions to send the mail or not? (1 Reply)
Discussion started by: ahmedwaseem2000
1 Replies

8. UNIX for Dummies Questions & Answers

check mail

hi can i know how to view(read) my mail in unix :( (4 Replies)
Discussion started by: babu@shell
4 Replies

9. Shell Programming and Scripting

Schedule a script to check mail?

Hi, I'd like to somehow schedule a task on my webserver, such that my account's mail is checked every 10-15 minutes and: a) any new e-mails received from a particular address are POST-ed to a PHP webpage on my server. b) any new e-mails received from a different particular address are... (2 Replies)
Discussion started by: stujones
2 Replies

10. Shell Programming and Scripting

how can I check the user's mail quota?

how can I check mail quota, and then how can I send mail to user whose quota get full??? :confused: For this which script must I use? (8 Replies)
Discussion started by: emreatlier
8 Replies
Login or Register to Ask a Question
runat(1)							   User Commands							  runat(1)

NAME
runat - execute command in extended attribute name space SYNOPSIS
/usr/bin/runat file [command] DESCRIPTION
The runat utility is used to execute shell commands in a file's hidden attribute directory. Effectively, this utility changes the current working directory to be the hidden attribute directory associated with the file argument and then executes the specified command in the bourne shell (/bin/sh). If no command argument is provided, an interactive shell is spawned. The environment variable $SHELL defines the shell to be spawned. If this variable is undefined, the default shell, /bin/sh, is used. The file argument can be any file, including a directory, that can support extended attributes. It is not necessary that this file have any attributes, or be prepared in any way, before invoking the runat command. OPERANDS
The following operands are supported: file Any file, including a directory, that can support extended attributes. command The command to be executed in an attribute directory. ERRORS
A non-zero exit status will be returned if runat cannot access the file argument, or the file argument does not support extended attributes. USAGE
See fsattr(5) for a detailed description of extended file attributes. The process context created by the runat command has its current working directory set to the hidden directory containing the file's extended attributes. The parent of this directory (the ".." entry) always refers to the file provided on the command line. As such, it may not be a directory. Therefore, commands (such as pwd) that depend upon the parent entry being well-formed (that is, referring to a direc- tory) may fail. In the absence of the command argument, runat will spawn a new interactive shell with its current working directory set to be the provided file's hidden attribute directory. Notice that some shells (such as zsh and tcsh) are not well behaved when the directory parent is not a directory, as described above. These shells should not be used with runat. EXAMPLES
Example 1: Using runat to list extended attributes on a file example% runat file.1 ls -l example% runat file.1 ls Example 2: Creating extended attributes example% runat file.2 cp /tmp/attrdata attr.1 example% runat file.2 cat /tmp/attrdata > attr.1 Example 3: Copying an attribute from one file to another example% runat file.2 cat attr.1 | runat file.1 "cat > attr.1" Example 4: Using runat to spawn an interactive shell example% runat file.3 /bin/sh This spawns a new shell in the attribute directory for file.3. Notice that the shell will not be able to determine what your current direc- tory is. To leave the attribute directory, either exit the spawned shell or change directory (cd) using an absolute path. Recommended methods for performing basic attribute operations: display runat file ls [options] read runat file cat attribute create/modify runat file cp absolute-file-path attribute delete runat file rm attribute permission changes runat file chmod mode attribute runat file chgrp group attribute runat file chown owner attribute interactive shell runat file /bin/sh or set your $SHELL to /bin/sh and runat file The above list includes commands that are known to work with runat. While many other commands may work, there is no guarantee that any beyond this list will work. Any command that relies on being able to determine its current working directory is likely to fail. Examples of such commands follow: Example 5: Using man in an attribute directory example% runat file.1 man runat getcwd: Not a directory Example 6: Spawning a tcsh shell in an attribute directory example% runat file.3 /usr/bin/tcsh tcsh: Not a directory tcsh: Trying to start from "/home/user" A new tcsh shell has been spawned with the current working directory set to the user's home directory. Example 7: Spawning a zsh shell in an attribute directory example% runat file.3 /usr/bin/zsh example% While the command appears to have worked, zsh has actually just changed the current working directory to '/'. This can be seen by using /bin/pwd: example% /bin/pwd / ENVIRONMENT VARIABLES
SHELL Specifies the command shell to be invoked by runat. EXIT STATUS
The following exit values are returned: 125 The attribute directory of the file referenced by the file argument cannot be accessed. 126 The exec of the provided command argument failed. Otherwise, the exit status returned is the exit status of the shell invoked to execute the provided command. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
open(2), attributes(5), fsattr(5) NOTES
It is not always obvious why a command fails in runat when it is unable to determine the current working directory. The errors resulting can be confusing and ambiguous (see the tcsh and zsh examples above). SunOS 5.10 22 Jun 2001 runat(1)