RunProgram redirection - how to get dd quiet

Linux specific forum
Marlin
Enthusiast
Enthusiast
Posts: 406
Joined: Sun Sep 17, 2006 1:24 pm
Location: Germany

RunProgram redirection - how to get dd quiet

Post by Marlin »

I'm trying to build a console application that calls dd very often.

Therefore I do not want to see the output of dd on the screen.
Like:

Code: Select all

1+0 Records in
1+0 Records out
dd does not seem to have a switch that makes it quiet
and I found a recommended solution to redirect the output
like in this example I found at linuxquestions.org:

Code: Select all

dd if=/dev/urandom of=tesfile count=1 bs=1k > /dev/null 2>&1
That however seems inapplicable when using RunProgram.
Trying that I get something like that:

Code: Select all

dd: unrecognized option `>'
dd gets that as a parameter and no redirection takes place.

Thinking about that and how to ask the question, I suddenly realized a solution like that:

Code: Select all

Program = RunProgram("dd", "if=/dev/sda1 bs=" + Str(#BlockSize) + " count=1 skip=" + Str(N - 1) + " of=block_" + RSet(Str(N), 8, "0"), #WrkDir, #PB_Program_Open | #PB_Program_Wait | #PB_Program_Error | #PB_Program_Read)
If Not Program
  PrintN("### dd Fehler bei block: " + Str(N))
  End
Else
  CloseProgram(Program)
EndIf
No more dd output on the screen. :)
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Re: RunProgram redirection - how to get dd quiet

Post by lexvictory »

Marlin wrote:That however seems inapplicable when using RunProgram.
Trying that I get something like that:

Code: Select all

dd: unrecognized option `>'
Because > is a shell feature, you need to use system_() for that (same with the * character in filenames) :wink:
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
Marlin
Enthusiast
Enthusiast
Posts: 406
Joined: Sun Sep 17, 2006 1:24 pm
Location: Germany

Post by Marlin »

lexvictory wrote:Because > is a shell feature, you need to use system_() for that (same with the * character in filenames)
That sounds very promissing. :D

Can you give me a hint, how it can be used?
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Post by lexvictory »

Code: Select all

system_("whatever command and its parameters etc that you want to be executed by a shell")
8)
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
Marlin
Enthusiast
Enthusiast
Posts: 406
Joined: Sun Sep 17, 2006 1:24 pm
Location: Germany

Post by Marlin »

This is nice and easy. :D

Shell power within PB 8)
Post Reply