Re: dev null placement?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2025-05-24 at 05:10 -0700, ToddAndMargo via users wrote:
> On 5/24/25 4:56 AM, Patrick O'Callaghan wrote:
> > On Sat, 2025-05-24 at 04:47 -0700, ToddAndMargo via users wrote:
> > > Hi All,
> > > 
> > > I still get all the trash with this:
> > > 
> > > echo $msg | /usr/bin/mailx $smtp -s $IAm" Disk Status" -r $From  $To
> > > 2>&1 > /dev/nul
> > > 
> > > I think I am putting the `2>&1 > /dev/nul` in the wrong place.
> > > 
> > > What am I doing wrong?
> > 
> > It's the wrong way round. The 2>&1 means "redirect the current fd 2 to
> > the same place as fd 1", but at this point fd 1 is still unchanged. You
> > also misspelled /dev/null but I assume that's a typo.
> > 
> > You want "... > /dev/null 2>&1".
> > 
> > poc
> 
> echo $msg | /usr/bin/mailx $smtp -s $IAm" Disk Status" -r $From  $To > 
> /dev/null 2>&1
> 
> Mailx hangs.  I think mailx thinks it is a parameter.

You didn't say what the problem was in your original post so I looked
no farther than the "2>&1" thing. I suggest running the whole script
under 'sh -x' to see what it's actually doing.

I would also run it through shellcheck to catch any obvious bloopers in
the syntax. I wou;d also enclose everything after the '|' in
parentheses so it executes in a subshell, in case the redirections
aren't doing what you think. 

poc
-- 
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux