Script Syntax on untarring file.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script Syntax on untarring file.
# 1  
Old 04-10-2009
Script Syntax on untarring file.

Trying to write a script to do the following.

scp to all redhat linux host and install a antivirus tarball. Need to know what additional syntax to use to untar the file and execute the install.sh inside the tarball and then remove the tarball on all remote hosts.

Here is what I have so far.

#!/bin/ksh
PATH=/usr/bin:/usr/sbin:/opt/local/bin:/usr/local/bin
PGM=`basename $0`
HOSTS=$1

[[ -z $HOSTS ]] && HOSTS="`grep -v \# /opt/local/etc/hosts|grep -i linux|nawk '{print $1}'`"

echo "$PGM: Installing Sophos AntiVirus Software"
for host in $HOSTS
do
printf "o PROCESSING HOST: %-20s\n" $host
ping $host 1>/dev/null 2>&1;
if (( $? )) ; then
echo "--Cannot contact host $host";
else
scp -q $host:/shares/cfgscripts/install.sophos.tar ${host:/opt/sophos-av $DIR/
esac
fi
fi;
done

Need some assistance on what to insert after scp the tarball to all the host.
# 2  
Old 04-10-2009
to extract a tarfile:

Code:
tar -xvf file.name

. . . . prefaced with appropriate ssh commands to do remotely.

if the files within the tar file are fully qualified directory-wise, this should work with the fullpath of file.name.
if they're not, and they're just relative, you'll need to do something like:

Code:
ssh hostname 'cd /there ; tar -xvf file.name'

# 3  
Old 04-10-2009
yeah that's right

assuming your tar is install.sophos.tar containing a folder install.sophos
adding this should do the job

Code:
ssh $host 'cd /there ; tar -xvf install.sophos.tar;
. ./install.sophos/install.sh; rm -rf install.sophos'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

URGENT Reading a file and assessing the syntax shell script URGENT

I am trying to write a shell script which takes an input file as an arguement in the terminal e.g. bash shellscriptname.sh input.txt. I would like for the file to be read line by line each time checking if the .txt file contains certain words or letters(validating the syntax). If the line being... (1 Reply)
Discussion started by: Gurdza32
1 Replies

2. UNIX for Dummies Questions & Answers

Grep through a .tar file without untarring it

Hi All, I need to grep through a .tar file without untarring it. Would you please help me with that ? The extension to this request is to use the cut command to extract the data from a particular field. Appreciate your quick look around (8 Replies)
Discussion started by: sanjaydubey2006
8 Replies

3. Shell Programming and Scripting

Cannot execute/finish script because of last line syntax error: unexpected end of file/token `done'

first of all I thought the argument DONE is necessary for all scripts that have or begin with do statements which I have on my script, However, I still don't completely understand why I am receiving an error I tried adding another done argument statement but didn't do any good. I appreciate... (3 Replies)
Discussion started by: wolf@=NK
3 Replies

4. UNIX for Dummies Questions & Answers

Help with untarring multiple files from tarred directories and subdirectories

Hi, I want to untar all log files from following tarred directory hierarchy Log_files.tar.gz/subject*.tar.gz/project*/*.log It means there are subject1.tar.gz to subject9.tar.gz and in those tarred subect directories there are project1 - project5 directories and in those directories there... (2 Replies)
Discussion started by: rv_trojan
2 Replies

5. UNIX for Advanced & Expert Users

Size of a tarball without untarring - Catch parent tar ball has sub tars

hi, I am in a weird situation. I have a parent tarball which contains 2 sub tarballs. The structure is such : Parent.tar.gz ---- > child1.tar.gz and child2.tar.gz I need to get the size of the parent tarball without untaring it I know that the command is gunzip -c parent.tar.gz | wc -c ... (1 Reply)
Discussion started by: mnanavati
1 Replies

6. Shell Programming and Scripting

untarring to the wrong dir

I am fairly new to scripting. I have a script to untar files as they come in. I keep scripts in one directory: /Scripts I get a tar'ed file in /Processing *CMD* $tar -xfv /Processing/File.tar When i run the script the untared files are placed in /Scripts i did some hunting around and... (2 Replies)
Discussion started by: purplebirky
2 Replies

7. Shell Programming and Scripting

script syntax error: unexpected end of file

Need help. I cannot find the reason for this error: here is the script (6 Replies)
Discussion started by: Lenora2009
6 Replies

8. Shell Programming and Scripting

Help on shell script : syntax error at line 62: `end of file' unexpected

Hi All, I have written a korn script (code pasted below). It is giving the error while debugging "new.sh: syntax error at line 62: `end of file' unexpected". I have re-written the whole code in VI and explored all help related to this error on this Unix forum and tried it. Somehow, I could... (7 Replies)
Discussion started by: schandrakar1
7 Replies

9. Solaris

problem while untarring a .tarz file

Hi all, How to untar a file having .tarz extension? i tried this tar -xvfz file.tarz but i'm getting error like tar: z: unknown function modifier Usage: tar {c|r|t|u|x}] {file | -I include-file | -C directory file}... Can anyone help me out in this.... Thanks in advance.... (2 Replies)
Discussion started by: gullapalli
2 Replies

10. Shell Programming and Scripting

.sh file syntax checking script

This isn't a question--its a solution! Below is a script that I wrote for my own script file development which does what the title says. Its the closest that you can get to compiling what are otherwise purely interpreted script files. I offer it here simply for the benefit of anyone else writing... (12 Replies)
Discussion started by: fabulous2
12 Replies
Login or Register to Ask a Question