Unix/Linux
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives FAQs Unix/Linux

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old July 2nd, 2008, 09:09 PM
PRC
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
why can't `dd` access /dev/stdout?

Hi All,

I want to get a random number by accessing /dev/urandom. But I get an
error

$dd if=/dev/urandom of=/dev/stdout bs=4 count=1
dd: opening `/dev/stdout': No such file or directory

So, can't `dd` access the device /dev/stdout?

Best Regards,
PRC
Jul 3, 2008

Reply With Quote
  #2  
Old July 2nd, 2008, 09:49 PM
Janis Papanagnou
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
why can't `dd` access /dev/stdout?

PRC wrote:
Hi All,
>

I want to get a random number by accessing /dev/urandom. But I get an
error

Does one of these help?

dd if=/dev/urandom bs=4 count=1 | whatever_todo_with_binary_data

dd if=/dev/urandom bs=4 count=1 2>/dev/null | od -t x1 -An

dd if=/dev/urandom bs=4 count=1 2>/dev/null | od -t x4 -An


Janis

>

$dd if=/dev/urandom of=/dev/stdout bs=4 count=1
dd: opening `/dev/stdout': No such file or directory
>

So, can't `dd` access the device /dev/stdout?
>

Best Regards,
PRC
Jul 3, 2008

Reply With Quote
  #3  
Old July 2nd, 2008, 11:30 PM
Dan Stromberg
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
why can't `dd` access /dev/stdout?

Wed, 02 Jul 2008 18:36:52 -0700, PRC wrote:

Hi All,
>

I want to get a random number by accessing /dev/urandom. But I get an
error
>

$dd if=/dev/urandom of=/dev/stdout bs=4 count=1 dd: opening
`/dev/stdout': No such file or directory
>

So, can't `dd` access the device /dev/stdout?
>

Best Regards,
PRC
Jul 3, 2008

I believe dd is close()'ing file descriptor 1, which corresponds to
stdout - so /dev/stdout ceases to exist for that process.

Fortunately, you can just use:

dd if=/dev/urandom bs=4 count=1

IW, dd's output defaults to stdout.


Reply With Quote
  #4  
Old July 3rd, 2008, 12:09 PM
Stephane CHAZELAS
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
why can't `dd` access /dev/stdout?

2008-07-03, 09:46(-04), Maxwell Lol:
[]
Insted of
dd if=/dev/urandom
You can also use
dd </dev/urandom
>

The if= and of= options provide a humorous backwards compatibility to JCL
I don't know of any reason to use them. Perhaps others do.

The of= one can be useful in combination with conv=notrunc
for shells that don't support 1<(csh).

See also the nonstandard (GNU only?) conv=excl/nocreat and
iflag/oflag.

--
S

Reply With Quote
Reply

Viewing: Web Development Archives FAQs Unix/Linux > why can't `dd` access /dev/stdout?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway