Help with ssh,tar and logging


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with ssh,tar and logging
# 1  
Old 07-23-2013
Help with ssh,tar and logging

Hi,

I'm successfully written a script which tar a directory and ssh's it over a remote server

Code:
tar cfv  - $SDIR  |  ssh $RHOST  "cat > $DDIR/backup.$BKPEXT.tar"

However, Im unable to log the activity to a file. i.e for example if I do

Code:
tar cfv  - $SDIR  |  ssh $RHOST  "cat > $DDIR/elc5.$BKPEXT.tar"  > logfile 2>&1

The logfile is empty even though the backup happens.

Please advice.

Thanks in advance

---------- Post updated at 08:00 PM ---------- Previous update was at 06:46 PM ----------

I have created a function to do the same job the tar command was doing and then I have redirected the function's output to the log file. It works.

Code:
TAR() {

   tar cfv  - $1  |  ssh $2  "cat > $3/project.tar"

 }


    TAR $SDIR $RHOST $DDIR  > $LOGFILE 2>&1

# 2  
Old 07-23-2013
Does the target tar file get created?

If you want the logfile created locally, you will probably need to do this:-
Code:
( tar cfv  - $SDIR  |  ssh $RHOST  "cat > $DDIR/elc5.$BKPEXT.tar" ) > logfile 2>&1




I hope that this helps,
Robin
Liverpool/Blackburn
UK
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tar file with logging and directory via parameter

Hi all, I am fairly new to shell scripting and I am trying the following: My shell script creates a tar file with files with the ending ~. The directory - where the files and sub directories are located - comes as a parameter when I call the script. Files that are archived will be written in... (1 Reply)
Discussion started by: neg42
1 Replies

2. Shell Programming and Scripting

Logging Remote SSH command (cannot log a java output)

Hi all I'm creating a script that runs a few commands on some boxes and everything can be logged EXCEPT the java -version command, there doesn't seem to be any output... Can anyone help explain why this does not work? Do I need to do something extra to append the output from the java... (3 Replies)
Discussion started by: Keepcase
3 Replies

3. UNIX for Dummies Questions & Answers

Automatic logging (capture screen output) of telnet/ssh sessions on a Solaris node

Hi I am working in Solaris 10 and I want to monitor logs for every telnet/ssh session that tries to connect to the server. I need these logs to be generated in a file that I can fetch using ftp. I am a new user and a stepwise detail will be great BR saGGee (3 Replies)
Discussion started by: saggee
3 Replies

4. UNIX for Dummies Questions & Answers

TAR OVER SSH

Hello, I have a server that has a tape drive attached to it in our company's DMZ. I want to backup the data on other servers onto this tape drive using a script. I will have to ssh into each machine and execute a tar command and instruct the tar command to send the data back to the server that... (5 Replies)
Discussion started by: mojoman
5 Replies

5. Shell Programming and Scripting

using SSH with my script and avoid logging in manually

Hi Guys. I have 3 variables $HOST $Username $Password I want to connect to a remote server using SFTP. usr/bin/sftp -o Cipher=blowfish $HostWhere do I put in the options for the username and pwd??? I have tried different ways and nothing works. It keeps coming back and promting me. ... (5 Replies)
Discussion started by: ramangill
5 Replies

6. UNIX for Advanced & Expert Users

difference between logging into unix through f-secure ssh client and telnet

hi, what is the difference between logging into unix through f-secure ssh client and telnet is there any more security check is involved can any one explain thanks in advance (1 Reply)
Discussion started by: trichyselva
1 Replies

7. UNIX for Advanced & Expert Users

ssh not logging users

We installed ssh on our AIX 5.3 box. The issue we are facing is that we dont get the users listed when we use 'w' or 'who'. After going through google without success, checked the www.openssh.org site. The FAQ section posted the solution that - How do I go about this? Has anyone faced an issue... (2 Replies)
Discussion started by: ranj@chn
2 Replies

8. UNIX for Advanced & Expert Users

What change in freeBSD OS to allow root logging using ssh?

Hi everybody, ] I would like to ask just simpe and short question. I am using freeBSD 6.0 and Debian Sarge. From Debian console I can log as root using ssh to bsd mashine but not vice versa. When I say in bsd console su I got sorry output, it does not allow me to su to root when I am logged... (5 Replies)
Discussion started by: 100days
5 Replies

9. OS X (Apple)

SSH Logging?

Does anybody know if MacOS X (10.3.X) is capable of logging ssh access? I want to be able to see who has logged into my system via SSH, similar to the way Apache or FTP logs access (/private/var/logs/). The only thing that I am finding right now is the the initiation of a PID in the "system.log",... (0 Replies)
Discussion started by: esser
0 Replies

10. UNIX for Advanced & Expert Users

SSH and command logging

Hi all... I've completed the task of deploying SSH over my 400 servers. I don't know if i'm right or wrong, but ssh doesn't do any command-logging, does it? Is there a app i can use to log all commands passed ( besides the usual .sh_history), whith no modification possible by the user, and how... (2 Replies)
Discussion started by: penguin-friend
2 Replies
Login or Register to Ask a Question