Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

mail ok in command line, not in scripts

Posted on 1998-03-27
19
Medium Priority
?
277 Views
Last Modified: 2010-04-21
I set up tcpwrapper on a linux machine.
It works fine (non-authorized hosts are banned), but in the deny file, I put the shell command (echo "sthing" | mail me@home.com). I know that this command line is executed with sh shell, which works fine on the linux machine.
If someone is banned I must receive the mail (It works perfectly on IRIX 6.3, exactly with the same shell command) and I receive nothing.
If I enter echo "sthing" | mail me@home.com under command line mode, I receive the mail.
Any suggestion?? Thanks.
0
Comment
Question by:steph84
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
  • +6
19 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 2009026
Is mail in your PATH?  What if you give an absolute path name?
0
 
LVL 1

Expert Comment

by:Tuff
ID: 2009027
I'm still kinda new to UNIX but in a perl script when you put in an email address it has to be written as such

anyname\@yourdomain.com

could this be possible?


0
 
LVL 84

Expert Comment

by:ozo
ID: 2009028
It doesn't have to be written as such.  It could also be written as
q(anyname@yourdomain.com)
But it sounds like steph84 is talking about a script for sh, not perl.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Expert Comment

by:eckspurt
ID: 2009029
What ozo suggests is probably correct.  Give the absolute path to the mail program (/bin/mail or /usr/bin/Mail).  System shell scripts should have a very restricted PATH set up so that there's minimal opportunity for a trojan horse to slip in.

0
 

Author Comment

by:steph84
ID: 2009030
I could try it today, it sounded nice but unfortunately, it didn't work....
Quite strange.
0
 
LVL 3

Expert Comment

by:percyn
ID: 2009031
Lets see the script.
What shell is it, tcsh or csh ?
0
 

Author Comment

by:steph84
ID: 2009032
(echo "client info: " %c "\nserver info: " %s "\ndate: " `date`) | /usr/bin/mail security@imaginet.fr

The %c and %s values are obtained by the wrapper and work fine.
According tcpwrapper man page, the shell command is interpreted by sh....

0
 
LVL 84

Expert Comment

by:ozo
ID: 2009033
How about using thr full path to `date`?

0
 

Author Comment

by:steph84
ID: 2009034
just as before,arghh!!!!
It's not very very very important if it doesn't work, but I'd like to understand...
I've increase to 150!

0
 
LVL 84

Expert Comment

by:ozo
ID: 2009035
How about:
(/usr/bin/echo "client info: " %c; /usr/bin/echo "server info: " %s ; /usr/bin/echo "date: "; /usr/bin/date) | /usr/bin/mailsecurity@imaginet.fr

Do you get any error messages?
0
 

Author Comment

by:steph84
ID: 2009036
I tried! Nothing, no mail,no error message, nothing.
I even tried (/usr/bin/echo "foo")|/usr/bin/mail security@imaginet.fr
I'm tired of this....
0
 
LVL 1

Expert Comment

by:mzito
ID: 2009037
I'm going to make two possible answers for this:
1) Are your permissions set on your mail program properly (i.e.  world executable)?
TCP Wrappers run shell commands as nobody, so that could cause a problem

2) Did you use the proper syntax if you're using the extended options?    
Tcp Wrappers can be compiled to use either the standard options or a much more flexible extended options.  If the second case is true, the following is an example hosts.deny:
ALL:ALL: twist echo "sthing" | mail  root@localhost

That will cause that command to be executed in place of the service daemon. I tried this example on my machine, and it worked fine.

Hope this helps.
Matt Zito
0
 
LVL 2

Expert Comment

by:António Sargento
ID: 2009038
I had tried the following script and work just fine in a SUN Solaris 2.5.1.

#!/bin/sh

echo "sthing" | mail antonio@leia

0
 
LVL 2

Expert Comment

by:António Sargento
ID: 2009039
I had tried the following script and work just fine in a SUN Solaris 2.5.1.

#!/bin/sh

echo "sthing" | mail me@machine

0
 
LVL 84

Expert Comment

by:ozo
ID: 2009040
That may even be an answer to the original question if you can get your tcpwrapper to call the script.
0
 

Author Comment

by:steph84
ID: 2009041
Sorry but this script work fine, even on my Irix 6.3, but not under tcpwrapper on the linux machine, That's my problem!
I've not enough time right now to try other things.....

0
 

Author Comment

by:steph84
ID: 2009042
Try others things recently, nothing worked.
mail work correctly, tried with whole path, with just echo "smthing" | mail, all rights are ok, ans exactly the same commans works under Irix.
Perhaps a bug from tcpwrapper under my version of linux.....

0
 
LVL 1

Expert Comment

by:hajek
ID: 2009043
if you are not sure if tcpwrapper call the script at all, try to do something what 100% does not need tty in the script (cp something_existing /tmp). If the file appears in /tmp, the script was called.

BTW, I do not know tcpwrapper, but if it runs under "nobody", what are permissions on the script you want to be run ??
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 300 total points
ID: 2009044
(echo "client info: " %c "\nserver info: " %s "\ndate: " `date`) | /usr/bin/mail  security@imaginet.fr

is this the "server program" you specified in /etc/inetd.conf ?
Have you tried to call a script in /etc/inetd.conf which executes
your commands? Like:
      /your_path/your_script %c %s

your_script:
(echo "client info: " $1 "\nserver info: " $2 "\ndate: " `date`) | /usr/bin/mail security@imaginet.fr

Probably some still mentioned suggestios about full pathnames are
usefull too :-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question