LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-17-2013, 07:38 AM   #1
keif
Member
 
Registered: Apr 2013
Posts: 107

Rep: Reputation: Disabled
Usage of /dev/null minus signs instead of greater-than signs


Hello everyone,

I'm having trouble understanding how the following command works:

Code:
/usr1/vision/bin/wd -s; /usr1/vision/bin/wd </dev/null 2</dev/null >/dev/null 2>/dev/null &
'wd' is a company proprietary software piece written in C. It's a process that monitors other proprietary programs written in C that reside in a Linux environment.

The command above restarts wd after an upgrade has been implemented.

I'm trying to understand how it works. One thing that baffles me is the use of minus signs /dev/null instead of greater than signs. Can anyone explain to me why they are used this way, or perhaps point me in the direction of a tutorial that explains it? Not having much luck searching on google.

Thanks.
 
Old 10-17-2013, 08:19 AM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
'-s' command line switch, most progs understand -h,--help or -? to give a summary of options that can be passed to it.

'<','>' io redirection '<' get input from ( in your example /dev/null ) '>' send output to ( again /dev/null ), /dev/null can be thought of as a black hole nothing gets out once its gone in.

2>/dev/null - slightly more complex , send stream 2 to /dev/null, all programs start with 3 basic streams open for them 0,1 and 2 which are stdin stdout and stderr. so this command sends error messages ( from stream 2 ) to /dev/null
 
1 members found this post helpful.
Old 10-17-2013, 09:30 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,849

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
/usr1/vision/bin/wd </dev/null 2</dev/null >/dev/null 2>/dev/null
/usr1/vision/bin/wd is the program you executed
</dev/null the standard input is redirected, the data is coming from /dev/null (means no data at all).
2</dev/null I have no idea, but I think it is completely meaningless
>/dev/null the standard output is redirected to /dev/null that means all the messages will be dropped
2>/dev/null the standard error is redirected to /dev/null, all the error messages are dropped

& means the program will be executed in the background (shell will not wait for it)
 
1 members found this post helpful.
Old 10-17-2013, 09:31 AM   #4
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
most important here is the semicolon ";". This tells the interpeter (shell) That the commands end here and is to be executed. So you can read the command as this:
Code:
/usr1/vision/bin/wd -s
/usr1/vision/bin/wd </dev/null 2</dev/null >/dev/null 2>/dev/null &
So start wd with the option s
after its done
start wd reading from stdin and stderr both inputs coming from /dev/null and we also redirect the output of wd into /dev/null on stdout and stderr whith everything put into background through the ampersand "&".
 
1 members found this post helpful.
Old 10-18-2013, 07:52 AM   #5
keif
Member
 
Registered: Apr 2013
Posts: 107

Original Poster
Rep: Reputation: Disabled
Thanks everyone for your help in my understanding of this command.
 
Old 10-20-2013, 09:32 AM   #6
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
A wild guess is that the "-s" switch is telling the process to shut down gracefully much like passing "stop" to scripts in init.d.
 
1 members found this post helpful.
Old 10-20-2013, 12:41 PM   #7
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
I agree: "command above restarts wd"
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Signs of getting compromised jmoschetti45 Linux - Security 5 01-28-2010 05:45 PM
Hello everybody - Clab signs in clab LinuxQuestions.org Member Intro 2 07-03-2008 06:47 AM
Signs Signs Everywhere Signs ....... dwcondu LinuxQuestions.org Member Intro 4 07-21-2007 01:14 PM
Do you need one of these signs? xpression General 2 09-23-2005 11:59 AM
Weird signs on startup k_brother Slackware 5 10-19-2003 04:05 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration