Sponsored Content
Top Forums Shell Programming and Scripting Extracting into a remote directory Post 302772153 by spacebar on Saturday 23rd of February 2013 02:44:09 PM
Old 02-23-2013
Quote:
Originally Posted by kumarjt
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.

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}"

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

extracting a field from directory path ??????

Hi I'll be getting a directory path as the input to the script. E.g. 1 abc/fsg/sdfhgsa/fasgfsd/adfghad/XXX/fhsad e.g. 2 sadfg/sadgjhgds/sd/dtuc/cghcx/dtyue/dfghsdd/XXX/qytq This input will be stored in a variable. My query is how to extract the field in a variable VAR which occurs... (15 Replies)
Discussion started by: skyineyes
15 Replies

2. UNIX for Advanced & Expert Users

Extracting the different files from directory & its sub directories

Hi Everyone, It would be helpful if someone helps me on this. Requirement: I have a directory which includes different types of files(for example *.java,*.class),but not restricted for only these types. I need to find the same types of file extensions from its directories and subdirectories... (3 Replies)
Discussion started by: rcvasu
3 Replies

3. Shell Programming and Scripting

Extracting Directory From Path

Hi guys. I'm doing some bash scripting and have run into a snag. Say I have the path: /home/one/two/three/ All I need is the 'three' while making a filename. Is there an easy way to do this? I've tried using grep (because I'm that smart.) cut (as I'm unable to tell how many fields there... (3 Replies)
Discussion started by: Drayol
3 Replies

4. Shell Programming and Scripting

sed/awk for extracting directory from file path

Hi, I have following path: set file_path = D:/forums/prac/somedir/new1/file1.txt or set file_path = E:/new/forums1/prac/somedir/new2/file2.txt I need to grep "somedir" from file path. In this case preceding directory "prac" remains same for both the paths, but directories preceding... (7 Replies)
Discussion started by: sarbjit
7 Replies

5. Shell Programming and Scripting

FTP files from different directory from remote server to one directory in local

Hi All, I want to search for .log files from folders and sub folders in remote server and FTP them to one particular folder in the local machine. I dont want to copy the entire directory tree structure, just have to take all the .log files from all the folders by doing a recursive search from the... (3 Replies)
Discussion started by: dassv
3 Replies

6. Shell Programming and Scripting

Zipping a directory and extracting to another server.

Hello everyone, I am trying to make a script in KSH that will zip an entire directory but leave out one file in that directory. I then need to send that zipped directory to another UNIX box. I am new to UNIX and would appreciate a good template to study from. (3 Replies)
Discussion started by: BrutalBryan
3 Replies

7. Shell Programming and Scripting

Replicate remote directory to local directory with ftp

I have system that generate files every 1 hours , i only have ftp connection from my local server to remote . $ ls -al -rw-r--r-- 1 water None 0 Feb 7 18:09 a.0800 -rw-r--r-- 1 water None 0 Feb 7 18:09 a.0900 -rw-r--r-- 1 water None 0 Feb 7 18:09 a.1000 is there any perl / php... (3 Replies)
Discussion started by: before4
3 Replies

8. Shell Programming and Scripting

One directory, extracting only files to a new directoy

I need a hint for extracting and copying only the loads of .mp3 files from one directory and its subdirectories to get them all into only one directory. This way I am doing gives me a identical copy with hundreds of subdirectories. But I just don't get it to extract only the files. Though I tried... (9 Replies)
Discussion started by: 1in10
9 Replies

9. UNIX for Beginners Questions & Answers

Extracting to another directory using cygwin

I have a file, in Windows, called php_0.27.tar.gz and want to extract it to C:\Program Files\PHP\script through Cygwin using this command: tar -xf php_0.27.tar.gz -C /Program Files/PHP/script But I got an error saying: tar: Files: Not found in archive I tried this command too: ... (8 Replies)
Discussion started by: steve120
8 Replies

10. UNIX for Beginners Questions & Answers

Extracting directory portion.

Dear Experts, I have some directory structure something like follows. I would like to cut portion of it. Would you please help me? I have to run this on several sql's. The directory path is dynamic. I have cut what comes after first "sql" string. Input:... (3 Replies)
Discussion started by: srikanth38
3 Replies
Test::Folder(3pm)					User Contributed Perl Documentation					 Test::Folder(3pm)

NAME
Test::Folder - test folder attributes SYNOPSIS
use Test::More ...; use Test::Folder; DESCRIPTION
This modules provides a collection of test utilities for folder attributes. Use it in combination with Test::More in your test programs. FUNCTIONS
folder_exists_ok(FOLDERNAME [, TESTNAME] ) Ok if the folder exists, and not ok otherwise. folder_not_exists_ok(FOLDERNAME [, TESTNAME] ) Ok if the folder does not exist, and not ok otherwise. folder_empty_ok(FOLDERNAME [, TESTNAME] ) Ok if the folder is empty (contains no files or subfolders), and not ok otherwise. folder_not_empty_ok(FOLDERNAME [, TESTNAME] ) Ok if the folder is not empty (contains any files or subfolders), and not ok otherwise. folder_readable_ok(FOLDERNAME [, TESTNAME] ) Ok if the folder is readable, and not ok otherwise. folder_not_readable_ok(FOLDERNAME [, TESTNAME] ) Ok if the folder is not readable, and not ok otherwise. folder_writable_ok(FOLDERNAME [, TESTNAME] ) Ok if the folder is writable, and not ok otherwise. folder_not_writable_ok(FOLDERNAME [, TESTNAME] ) Ok if the folder is not writable, and not ok otherwise. folder_executable_ok(FOLDERNAME [, TESTNAME] ) Ok if the folder is executable, and not ok otherwise. folder_not_executable_ok(FOLDERNAME [, TESTNAME] ) Ok if the folder is not executable, and not ok otherwise. TO DO
There are probably some more folder attributes that can be tested. If you need them, please ask (or better yet, contribute code!). AUTHOR
Martin 'Kingpin' Thurn, "mthurn at cpan.org", <http://tinyurl.com/nn67z>. BUGS
Please report any bugs or feature requests to "bug-test-dir at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Dir>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. SUPPORT
You can find documentation for this module with the perldoc command. perldoc Test::Folder You can also look for information at: o RT: CPAN's request tracker <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Dir> o AnnoCPAN: Annotated CPAN documentation <http://annocpan.org/dist/Test-Dir> o CPAN Ratings <http://cpanratings.perl.org/d/Test-Dir> o Search CPAN <http://search.cpan.org/dist/Test-Dir> ACKNOWLEDGEMENTS
COPYRIGHT &; LICENSE Copyright (C) 2007-2008 Martin 'Kingpin' Thurn This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2011-02-20 Test::Folder(3pm)
All times are GMT -4. The time now is 06:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy