Sponsored Content
Top Forums Programming shell scripting problems involving operations with remote machine Post 302483897 by srijith on Wednesday 29th of December 2010 02:24:03 AM
Old 12-29-2010
shell scripting problems involving operations with remote machine

Hi,
i have been developing a shell script to transfer a set of files from one ubuntu system to another.

Task: while executing the script the files ( ls, dir, cat) in the source machine should transfer to destination machine(at /home/mac/mac/bin)

While the script is executed once again, It should create a backup file( bacup_date_time) and move all the old files in destination machine(at /home/mac/mac/bin) ti this backup file.

Here is the code i tried with,

Code:
ssh mac@192.168.3.247

filename=bacup_`date +%b_%d_%Y_%H_%M_%S`

mkdir /home/mac/mac/bin/$filename

cp /home/mac/mac/bin/*.bin /home/mac/mac/bin/$filename

scp /bin/ls /bin/dir /bin/cat mac@192.168.3.247:/home/mac/mac/bin

exit

My problem is I am able to run this script, but the backup files are not created.

I can see the files getting transfered, but I am not able to make a new backup directory and also copy the old files in remote machine.


please help me on this.
Thanks in advanceSmilie

---------- Post updated at 12:54 PM ---------- Previous update was at 12:05 PM ----------

Don't mind, I got self help and the problem is solved by adding "here document" concept Smilie

Code:
filename=bacup_`date +%b_%d_%Y_%H_%M_%S`

ssh mac@192.168.3.247 <<EOT

mkdir /home/mac/mac/bin/$filename

cp /home/mac/mac/bin/ls /home/mac/mac/bin/$filename
cp /home/mac/mac/bin/dir /home/mac/mac/bin/$filename
cp /home/mac/mac/bin/cat /home/mac/mac/bin/$filename



EOT
scp /bin/ls /bin/dir /bin/cat mac@192.168.3.247:/home/mac/mac/bin
exit


Last edited by srijith; 12-29-2010 at 02:58 AM..
This User Gave Thanks to srijith For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Setting environment variable on a remote solaris machine using shell script

Hi, I am trying to set environment variable on a remote machine. I want to do it by running a shell script Here's what I am doin rsh <remote-hostname> -l root "cd /opt/newclient; . ./setp.sh" In setp.sh, I have ############################# cd ../newlib; export... (1 Reply)
Discussion started by: eamani_sun
1 Replies

2. Shell Programming and Scripting

file operations in shell scripting

hi All, my query... 1.I Have to search for the files in the root directory. 2.i have to search for a pattern in all the files in the root directory and then replace them with a new pattern. 3.Rename the file Explanation: if ABC is the root folder and has 3 subfolders and there are 15... (9 Replies)
Discussion started by: adityamahi
9 Replies

3. Shell Programming and Scripting

shell scripting on unix/mysql problems

Hi, I have written a shell script for oracle on unix that does a df for specific files, and then will display the size, Avail, % used and the difference from yesterday to today. I have been asked to place it on some MySql databases that run onn unix and linux also, but when I try to run them I... (2 Replies)
Discussion started by: cat55
2 Replies

4. Shell Programming and Scripting

Shell scripting problems - Commands not on local machine

Hello all- I have done a lot of searching tonight, but all leads seem to be dead ends. Forgive me if this has been covered, but I've searched the forum and the internet. I am having trouble building a shell script which uses SSH to login to our schools 1024 cluster grid. The issue that I am... (1 Reply)
Discussion started by: Sagan
1 Replies

5. Shell Programming and Scripting

Password change logic for remote machine using shell and expect

Day before yesterday,I got the success creating a shell script using expect tool and now it is running successfully on the server. Now I want to make some changes in paswwordchanger.sh as you can see it can handle only one user i.e dbaguest and not other user.So I am thinking the logic how I can... (0 Replies)
Discussion started by: manish_1678
0 Replies

6. Shell Programming and Scripting

executing command in a remote machine through ssh - shell script

Hi All, i have two machines like x and y . my requirement is i should connect to machine Y from x through ssh connection . and do some operation such as copy and move and delete files in Y machine . i tried with this code but it is doing in machine x only . and i need to exit from Y when... (1 Reply)
Discussion started by: rateeshkumar
1 Replies

7. UNIX for Dummies Questions & Answers

how to use ssh to run shell script on a remote machine?

how to use ssh to run shell script on a remote machine? ssh user@remote sh ./script.unx i ran the above command ./script.unx HAS NOHUP COMMAND IN ITS BODY, I AM GETTING ERROR AS NOHUP NOT FOUND... i tried to run that script from remote server, its working fine do ineed to set... (6 Replies)
Discussion started by: only4satish
6 Replies

8. OS X (Apple)

Quit a shell script thats running on a remote machine

I'm in a situation where I am executing a shell script(Bash) on another machine remotely using ssh, and for various reasons sometimes need to quit it and restart it. The shell script being run does many different things, so its hard to know what process to kill on the remote machine, and even if I... (2 Replies)
Discussion started by: TheDrizzle
2 Replies

9. UNIX for Dummies Questions & Answers

Execute shell script in remote machine

Hi All, We have 2 servers A and B. B is having a sctipt called b.sh in path /home/dev/scripts. Now my requirement is i want to execute b.sh from server A. Kindly help me. (3 Replies)
Discussion started by: Girish19
3 Replies

10. Shell Programming and Scripting

Execute shell script on remote machine

I want to execute a shell script(set of commands) on remote machine and that script takes input from text file(local machine). Please refer below: ssh user@hostname 'bash -s'< ./test.sh file.txt But i got the error file.txt doesn't exist. Can anyone help me on this. Content of test.sh: ... (2 Replies)
Discussion started by: manishtri88
2 Replies
mac(1)								   User Commands							    mac(1)

NAME
mac - calculate message authentication codes of the input SYNOPSIS
/usr/bin/mac -l | [-v] -a algorithm [-k keyfile] [file...] DESCRIPTION
The mac utility calculates the message authentication code (MAC) of the given file or files or stdin using the algorithm specified. If more than one file is given, each line of output is the MAC of a single file. OPTIONS
The following options are supported: -a algorithm Specifies the name of the algorithm to use during the encryption or decryption process. See USAGE, Algorithms for details. Note: Algorithms for producing general length MACs are not supported. -k keyfile Specifies the file containing the key value for the encryption algorithm. Each algorithm has specific key material require- ments, as stated in the PKCS#11 specification. If -k is not specified, mac prompts for key material using get- passphrase(3C). For information on generating a key file, see dd(1M) or System Administration Guide: Security Services. -l Displays the list of algorithms available on the system. This list can change depending on the configuration of the crypto- graphic framework. The keysizes are displayed in bits. -v Provides verbose information. USAGE
Algorithms The supported algorithms are displayed with the -l option. These algorithms are provided by the cryptographic framework. Each supported algorithm is an alias to the most commonly used and least restricted version of a particular algorithm type. For example, md5_hmac is an alias to CKM_MD5_HMAC. These aliases are used with the -a option and are case-sensitive. Passphrase When the -k option is not used during encryption and decryption tasks, the user is prompted for a passphrase. The passphrase is manipulated into a more secure key using the PBKDF2 algorithm specified in PKCS #5. EXAMPLES
Example 1: Listing available algorithms example$ mac -l Algorithm Keysize: Min Max ----------------------------------- des_mac 64 64 sha1_hmac 8 512 md5_hmac 8 512 Example 2: Getting the message authentication code for a file example$ mac -v -k mykey -a sha1_hmac /export/foo sha1_hmac (/export/foo) = 913ced311df10f1708d9848641ca8992f4718057 EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
digest(1), dd(1M), getpassphrase(3C), libpkcs11(3LIB), attributes(5), pkcs11_softtoken(5) System Administration Guide: Security Services RSA PKCS#11 v2.11 http://www.rsasecurity.com/rsalabs/pkcs/pkcs-11 RSA PKCS#5 v2.0 http://www.rsasecurity.com/rsalabs/pkcs/pkcs-5 SunOS 5.10 23 Apr 2004 mac(1)
All times are GMT -4. The time now is 01:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy