Need to create a simple script using MD5, SSH...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to create a simple script using MD5, SSH...
# 50  
Old 03-09-2011
Quote:
Originally Posted by zixzix01
Thanks for your input Chubler, I did put in those corrections
You might want to undo the extra >$TMP, it's pointless. see above.

Keep the extra quotes though.

---------- Post updated at 03:16 PM ---------- Previous update was at 03:14 PM ----------

Quote:
Originally Posted by zixzix01
Sorry Corona, defensive quoting?
The difference between $fname and "$fname" is that the former will split into several arguments if $fname happens to have a space in it, while "$fname" will remain as one argument with a space in it. Splitting would be bad, as it might try to handle "/path/dir with space/file" as three files, "/path/dir", "with", and "space/file", and complain that it can't find any of them.

He's put it in quotes like "$fname", then added another layer of quotes like "\"$fname\"" to make sure it gets quoted on the remote machine too -- one layer of quotes gets stripped off of whatever you feed into ssh.
This User Gave Thanks to Corona688 For This Post:
# 51  
Old 03-09-2011
Dont worry about truncating the file, corona688 is right the > on the SSH line will truncate the file anyway.

I was thinking of ssh failing and the file remaining with previous data, but that can't happen.
This User Gave Thanks to Chubler_XL For This Post:
# 52  
Old 03-09-2011
Oh yes I didn't I just tested it and it worked just the same like you said Corona!

I just don't understand how he got the same thing with under 15 lines of code! I mean I understand that he created all the scripts for the company and the man's a wizard with regular expressions and scripting, but still. I understand your way, kind of!

He had I think 3 loops and used hostname and hosts, redirected my truncated directory sync. Forgot why he told me to make sure and use hostname as well as hosts files! Don't know! I'll ask and updated it here, just for FYI if it means something fot the script!

Thanks and now I gotta go get yelled at for getting help with this. He won't but I'm just very much out of my element with programming and scripting.

P.S. Do you guys think that it would be good for me to pickup some stuff about like C, C++, Pearl, Python, etc! I know that a lot but we'll see!
# 53  
Old 03-09-2011
Quote:
Originally Posted by zixzix01
I just don't understand how he got the same thing with under 15 lines of code!
After all this struggling I'm just happy to have something that a) works, b) works well, c) is readable. If I knew then what I know now about your system I could've shrunk it a bit.

Some of the 'bloat' is error-checking though, and probably should be kept.
Quote:
I know that a lot but we'll see!
...I'm not sure where to begin. That's a lot. Smilie
This User Gave Thanks to Corona688 For This Post:
# 54  
Old 03-09-2011
Quote:
That's a lot.
Haha, and yes it is! But I want to get good at scripting quickly and efficiently! Asap!

Thanks a million, and I'll try to work with the bloat and see what kind of things I get!
# 55  
Old 03-11-2011
Just a couple of more questions!

Hey Corona688,

Just a couple of more questions. I'm trying to better understand these scripts. Some of the things you used:

Is there any other way of doing this input, or is this the only way that the loop will take the file!?
Code:
done < /home/izivanov/iz3

What is this redirection and what does the whole thing >&2 mean?

Code:
echo "local hash is ${hash}" >&2

And also what did you do with this part, I don't understand it!

# Skip errors
Code:
[ "$?" -eq 0 ] || continue

Thanks again for taking time to look at this!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

2. Shell Programming and Scripting

Create simple script

Dear all, I have a directory named A and some subdirectories named B, C, D with .xml files. I want to use the following command to strip the file. sed -re ':start s/<*>//g; /</ {N; b start}' file.xml > file.xml At the same time, I want to remove the blank lines using sed '/^$/d' How can... (6 Replies)
Discussion started by: corfuitl
6 Replies

3. Shell Programming and Scripting

How to create a simple copy script?

Guys I want to do this: copy: /var/router/system1/config/backup/install.put /var/router/system2/config/backup/install.put /var/router/system3/config/backup/install.put /var/router/system4/config/backup/install.put into: /var/router/system1/config/install.dat... (22 Replies)
Discussion started by: DallasT
22 Replies

4. Shell Programming and Scripting

Create md5 sums and archive the resulting md5 files

Hello everyone, I am looking to basically creating md5sum files for all iso files in a directory and archive the resulting md5 files into a single archive in that very same directory. I worked out a clumsy solution such as: #find files for which md5sum are to be created and store the... (1 Reply)
Discussion started by: SurfTranquille
1 Replies

5. Shell Programming and Scripting

How to create a simple shell script to backup

Hello - I am in process of deleting many files which are older than 4 weeks. For example I am inside: /subsystem/prod/ Files are with various extentions, but anything older than 4 weeks should be deleted. What would be the most simplest script to acheive this? (4 Replies)
Discussion started by: DallasT
4 Replies

6. Solaris

How to create a simple background script on Solaris

I have a local account for a unix server. The idle timeout for the account is around 10 mins. I have to login to the server multiple times during the day. Is there a way to increase the idle timeout or may be a script that I can run on background so it is not idle. Something like echo date every 9... (3 Replies)
Discussion started by: vinaysa
3 Replies

7. Shell Programming and Scripting

Simple SSH script

I have several unix servers, I need to logon to each server and find out if an id exists on that server. I need a simple script for this, i have come up with the following script, but I cannot bring the output of a child process on the remote server. for i in `cat SERVER_LIST` do ssh $i... (5 Replies)
Discussion started by: ramky79
5 Replies

8. Shell Programming and Scripting

Simple Script to create folders

Hi I want to write a small script that will create folders named from `AAAA' all the way to `ZZZZ'. That is: `AAAA' `AAAB' `AAAC' ... `AABA' `AABB' `AABC' ... `ABAA' `ABAB' `ABAC' ... `ABBA' ... `ZZZZ' (4 Replies)
Discussion started by: ksk
4 Replies

9. Shell Programming and Scripting

Modifying simple commands to create a script

Can anyone direct me to a resource that explains scripting in simple terms? I have visited many sites and browsed this forum and have yet to find simple explanations. (8 Replies)
Discussion started by: rocinante
8 Replies

10. Shell Programming and Scripting

How to create md5 Hash variable?

I have a script that runs the grub-md5-crypt command based on whether the pass_value variable is a non-zero string. The md5 hash is being created in the /opt/hostconfigs/$HOST file, but I can't echo $md5_value. It is blank. Is there a way to create and echo a md5 hash variable? if then... (1 Reply)
Discussion started by: cstovall
1 Replies
Login or Register to Ask a Question