The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Direct the output of a script to a log file autosys_nm Shell Programming and Scripting 5 08-27-2008 08:16 AM
compare file size from a output file from a script moustik Shell Programming and Scripting 7 11-07-2007 10:17 AM
scp output fm script won't go to file nmikes Shell Programming and Scripting 7 01-31-2007 06:53 PM
Output of script to a file sumeet UNIX for Advanced & Expert Users 3 11-29-2006 12:12 PM
File name of a script output cheo_pr Shell Programming and Scripting 3 09-01-2005 05:40 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 1.00 average. Display Modes
  #1 (permalink)  
Old 10-03-2008
stuaz stuaz is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 13
Talking Script that will output everything to file

Hello,

I am kinda new to Unix scripting, haven't really dabble very deep, but I am trying to at the moment.

Currently I am attempting to create a install script for my software. However what i would like to do is EVERYTHING that is outputted to screen (Including user input), is sent to a log file of my chosing.

E.g: variable set for Xfile name to X directory.

I know this is probably quite trivial but i would love it if you could give me some help if at all possible.

I am writing this sh script on on Linux (CentOS) .

Also, if you have any good links to some good Shell scripts commands or cheat sheets that would be awesome!.

Many thanks again.
  #2 (permalink)  
Old 10-03-2008
nullwhat nullwhat is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 25
type

echo put this in a file called file.txt > file.txt

using the ">" you just output to a file.txt


cat file.txt


want to add something else use ">>" to put more on the end

echo i want to add more stuff to my file.txt >> file.txt

cat file.txt
put this in a file called file.txt
i want to add more stuff to my file.txt

IS THAT WHAT YOU WANTED?
  #3 (permalink)  
Old 10-04-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,418
you can also use tee command
  #4 (permalink)  
Old 10-04-2008
stuaz stuaz is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 13
I understand how to use "> log_file" but that would only work for one command, and i would have to put that everywhere in the script!

I want everything that my script outputs to the screen placed in a log file, including user input.

Is there no an easier way of doing this?

Such as

Start Script --

Create logfile/Start recording --

Commands issued by the script
Commands issued by the script
Commands issued by the script
Commands issued by the script
User input
Commands issued by the script
Commands issued by the script
Commands issued by the script

Stop recording

End of script.
  #5 (permalink)  
Old 10-04-2008
fed.linuxgossip fed.linuxgossip is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 99
if you are using linux ( redhat or centos in particular, as I have to explored on other Nix'es ) are you looking for : script command



[root@server ~]# script
Script started, file is typescript
[root@server ~]# ls -l typescript
-rw-r--r-- 1 root root 0 Oct 4 17:20 typescript
[root@server ~]# cat typescript
[root@server ~]# ls -l typescript
-rw-r--r-- 1 root root 0 Oct 4 17:20 typescript
[root@server ~]# vi 123
[root@server ~]# vi 12345
[root@server ~]# ls -l typescript
-rw-r--r-- 1 root root 0 Oct 4 17:20 typescript
[root@server ~]#
[root@server ~]# exit
Script done, file is typescript
[root@server ~]# ls -l typescript
-rw-r--r-- 1 root root 1375 Oct 4 17:21 typescript
[root@server ~]# cat typescript
Script started on Sat 04 Oct 2008 05:20:08 PM IST
[root@server ~]# ls -l typescript
-rw-r--r-- 1 root root 0 Oct 4 17:20 typescript
[root@server ~]# cat typescript
[root@server ~]# ls -l typescript
-rw-r--r-- 1 root root 0 Oct 4 17:20 typescript
[root@server ~]# vi 123
[root@server ~]# vi 12345
[root@server ~]# ls -l typescript
-rw-r--r-- 1 root root 0 Oct 4 17:20 typescript
[root@server ~]#
[root@server ~]# exit

Script done on Sat 04 Oct 2008 05:21:02 PM IST
[root@server ~]#
Closed Thread

Bookmarks

Tags
linux commands, unix commands

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:58 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0