|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Extracting into a remote directory
I need to fit in a module in my Korn Shell script which would extract file_archive.tar.gz residing in the folder /apps/Test of my local machine into a folder /global/ in a remote machine server1.
Please help me on this regard. Thanks Kumarjit. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Many ways to skin a cat...
Kumarjit, this really depends on the OS and way the remote directory is accessed. For instance if you mount a remote windows box, I strongly recommend using gvfs to mount the remote local directory and file roller to decompress. If it is a unix box, there are a few options. One would be to simply mount the remote file system. In my example I create a directory underneath my operational directory, the directory is called "remote". Next .. Code:
echho 'test' > test.txt tar -pczf name_of_your_archive.tar.gz test.txt ls name_of_your_archive.tar.gz remote test.txt If the objective is to now deflate into remote... Code:
cd remote tar -zxvf ../name_of_your_archive.tar.gz ls test.txt If it is not locally mounted you can use still other approaches. Quote:
|
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Quote:
If you are going from/to a *nix type os, you could do something like this to transfer the file and untar it: Code:
#!/usr/bin/ksh
# script: example_scp_ssh.sh
# Transfer file to remote
scp -v -o IdentityFile=~/.ssh/id_rsa -o BatchMode=yes /apps/Test/archive.tar.gz user@remote:/global
rc=$?
if [[ $rc != 0 ]] then
print "***Error occurred transferring file...$rc" `date "+%Y-%m-%d-%H.%M.%S"`
else
print "***Successful transfer of file...$rc" `date "+%Y-%m-%d-%H.%M.%S"`
fi
# Run cmd on remote
ssh_results=`ssh user@remote '. ./.profile;tar -zxvf /global/archive.tar.gz'`
print "${ssh_results}" |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Replicate remote directory to local directory with ftp | before4 | Shell Programming and Scripting | 3 | 02-19-2013 01:31 AM |
| Zipping a directory and extracting to another server. | BrutalBryan | Shell Programming and Scripting | 3 | 12-28-2011 01:26 PM |
| FTP files from different directory from remote server to one directory in local | dassv | Shell Programming and Scripting | 3 | 12-16-2011 10:01 AM |
| Extracting Directory From Path | Drayol | Shell Programming and Scripting | 3 | 04-15-2011 10:05 PM |
| extracting a field from directory path ?????? | skyineyes | Shell Programming and Scripting | 15 | 07-10-2007 12:42 AM |
|
|