LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   command output to text file? (https://www.linuxquestions.org/questions/linux-newbie-8/command-output-to-text-file-489383/)

meniscus 10-04-2006 10:48 AM

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?

Thanks,
meniscus

tredegar 10-04-2006 10:54 AM

/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

HTH

stress_junkie 10-04-2006 10:56 AM

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.
Code:

$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.

meniscus 10-05-2006 03:40 AM

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 time...like a daemon? Can you suggest any tutorials where i might learn how to do this?

Wim Sturkenboom 10-05-2006 05:29 AM

Check man crontab or check the internet for crontab tutorial


All times are GMT -5. The time now is 04:58 AM.