Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 01 Sep 2014, 20:08
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
What's the difference in these two lines of code?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [7 Posts]  
Author Message
RSH


Joined: 05 Sep 2011
Posts: 2420
Location: Germany

PostPosted: Sat 12 Jan 2013, 00:32    Post subject:  What's the difference in these two lines of code?  

Hi.

I hope anyone can tell me what is the difference (in functionality) between the two following code lines:
Code:
cp -af /root/puppy-reference /tmp/root/

Code:
cp -af /root/puppy-reference /tmp/root/ 2>/dev/null

Thanks

RSH

_________________
LazY Puppy
RSH's DNA
SARA B.
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5016
Location: Arizona, U.S.A.

PostPosted: Sat 12 Jan 2013, 01:09    Post subject:  

Hi RSH; 2> redirects the error output of the command.
/dev/null is a "black hole" that swallows whatever is sent to it.

Code from my AppPkg mount file:
Code:
Etc=`find etc/* 2> /dev/null`

If there`s no etc dir. in the current dir., there`s no error output in a VT.
Back to top
View user's profile Send private message 
matiasbatero


Joined: 11 Oct 2012
Posts: 60
Location: Mar del Plata, Argentina

PostPosted: Sat 12 Jan 2013, 12:39    Post subject:  

2> /dev/null is very usefull when you wants to make a silent scripts.
Adding 2> /dev/null, you send the ouput error to the trash, and nothing is printed on your screen.
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3261
Location: Ontario

PostPosted: Sat 12 Jan 2013, 14:57    Post subject:  

Code:

cp -af /root/puppy-reference /tmp/root/  2>/tmp/error$$


I have found that funnelling the error
message to a file in /tmp is useful in studying whether
my partition is filled up. I do a 'grep' of /tmp/error$$
to see if there is text 'no space left' or whatever that error message is.


I used that technique in my pet packages 'Extract-pet' and 'Extract-debian'
to warn the user that there is not enough disk space to do extraction.

It works well with 'mv' command or 'mv -i' command I believe.

____________________________________________________
Back to top
View user's profile Send private message 
postfs1


Joined: 27 Mar 2010
Posts: 831

PostPosted: Sat 12 Jan 2013, 15:08    Post subject:  

Maybe: request for a third-party programmatic option.
_________________
  • I don't know why laboratories are named a hospitals.
  • The alive personage is like a tea bag with granules of unknown density inside, at that one the packet was made of organic material and was placed in the evaporated liquid or liquid.

Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5016
Location: Arizona, U.S.A.

PostPosted: Sat 12 Jan 2013, 23:31    Post subject:  

I`ve always thought that copy and move should check target free space.
What`s the point in even beginning to copy if there`s not enough space?

Remembering the days of copying to a floppy only to have it fail at the end
because the darn thing has enough bad sectors that it won`t hold the data.
Back to top
View user's profile Send private message 
RSH


Joined: 05 Sep 2011
Posts: 2420
Location: Germany

PostPosted: Sun 13 Jan 2013, 00:52    Post subject:  

Hi.

Thanks to all for clearing this. I was a bit afraid to have left something out that would be necessary - in all of my programs. Laughing

RSH

_________________
LazY Puppy
RSH's DNA
SARA B.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [7 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0566s ][ Queries: 12 (0.0040s) ][ GZIP on ]