Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-04-2006, 11:48 AM   #1
Registered: May 2006
Posts: 70

Rep: Reputation: 15
command output to text file?

Ive installed a package called smartmontools and i am attempting to write the op to a file in my home directory.

With the command

$sudo smartctl -a /dev/hda

evrything works fine. Its ops the info to the terminal

When i type

$sudo smartctl -a /dev/hda > /Home

It gives me an error...

bash: /Home: Permission denied

What am i doin wrong?

Old 10-04-2006, 11:54 AM   #2
LQ 5k Club
Registered: May 2003
Location: London, UK
Distribution: Debian 11
Posts: 6,126

Rep: Reputation: 418Reputation: 418Reputation: 418Reputation: 418Reputation: 418
/Home is a file called Home in your root (/) directory. You probably aren't allowed to create a file there.
Try $sudo smartctl -a /dev/hda > /home/yourusername/filename

Old 10-04-2006, 11:56 AM   #3
Senior Member
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
The syntax that you are using means that you are trying to create a file named Home in the top level directory. Try this instead.
$sudo smartctl -a /dev/hda > $HOME/smartctl-output.txt
In my example I am using the environment variable HOME as the directory to write into. Then I am adding a file name to hold the output of the smartctl command. This will create a file named smartctl-output.txt in your home directory when you run the command.
Old 10-05-2006, 04:40 AM   #4
Registered: May 2006
Posts: 70

Original Poster
Rep: Reputation: 15
It worked! Brilliant! Thanks!

Is it possible for me to have that run periodically say every 5 mins without having to write the command in the terminal each a daemon? Can you suggest any tutorials where i might learn how to do this?
Old 10-05-2006, 06:29 AM   #5
Wim Sturkenboom
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
Check man crontab or check the internet for crontab tutorial


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
pipe output to append to a text file davee Linux - Newbie 5 03-22-2016 08:44 PM
Media player output text file for now playing Berticus Linux - Software 0 08-05-2006 12:05 AM
how to enumerate first line of text file to standard output? zero79 Linux - General 1 07-07-2004 07:37 PM
Pipe telnet session output to text file joshlamerritt Linux - Software 3 02-10-2004 09:42 PM
Piping output to a text file joadoor Linux - Newbie 7 04-19-2002 04:50 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:55 AM.

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