Sponsored Content
Top Forums Shell Programming and Scripting ksh scripting SSH to Compare File Sizes Post 303025351 by RudiC on Wednesday 31st of October 2018 09:07:25 AM
Old 10-31-2018
You will have to define the function on each node separately, and the local variables like FILESZ1 won't be available there.


How about creating a server file like
Code:
$ cat svctl
user@server2
user@server3
user@server4

to which you could even add your local server entry (user@server1) as the first line provided it has an sshd service running, and then, using shell arrays for the file sizes
Code:
$ FILE1=/root/directory1/files/file1.fil
$ FILE2=/root/directory2/files/file2.fil 
$ while read SV; do { read FILESZ1[++CNT]; read FILESZ2[CNT]; } <<< $(ssh -n $SV "stat -c%s $FILE1; stat -c%s $FILE2"); done <  svctl

leaving you with two file size arrays of four elements each to work upon locally. Admittedly, this has been tested on bash only, as I don't have a ksh machine here, but corrections - if necessary at all - should be minor.
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

compare file sizes

Is there a command that will return the name of the largest file within a directory? If so, can I set the returned filename into a variable? (4 Replies)
Discussion started by: joli
4 Replies

2. Shell Programming and Scripting

to compare total directory structure and get sizes of all f on two different servers

Hello every one, Iam newbie to this forum and shell programming &scripting. i needed to compare each and every folder of two separate servers. Actually I have copied some directory structure from one server to second server, to build on second server the files all should be copied... (3 Replies)
Discussion started by: mannam srinivas
3 Replies

3. Shell Programming and Scripting

how to compare file sizes

hi ls -l * | sed 's/\+/ /g' | cut -f5 -d " " >out1 ls -l * | sed 's/\+/ /g' | cut -f5 -d " " >out2 diff out1 out2 i tried this it will work fine and i can see difference but i need a script which should neglect, if the difference b/w files is small and it should display... (5 Replies)
Discussion started by: revenna
5 Replies

4. Shell Programming and Scripting

KSH: Compare variable to $1 in an input file

Hello, I am working with KSH on AIX and I have 2 files generated from different sources... as seen below: FILE1 FILE2 AAA AAA@ABS0001C BBB BBB@ABS0003D CCC CCC@ABS0023A DDD DDD@ABC0145D EEE EEE@ABS0090A FFF FFF@ABS0002A GGG GGG@ABC0150D HHH FILE1 is main main data source,... (4 Replies)
Discussion started by: right_coaster
4 Replies

5. HP-UX

compare file percent sizes

I need to get a file size and compare it to a previous day file size. If it's larger or smaller by 50 percent I'll replace the new with the old. I know how to get the file sizes but do not know how to calculate if it's 50 percent difference. Thanks for your help. (2 Replies)
Discussion started by: jkuchar747
2 Replies

6. UNIX for Dummies Questions & Answers

Compare two file sizes.

Hi everyone! I need to compare two file sizes. One of them (size) will be stored in a flat file and the other coming from a listed file. I can now get the first file size using: SIZE=`ls -l $DOCTYPE | awk '{print $5}'` 1. How can I store this value in a flat file? 2. How... (2 Replies)
Discussion started by: mrreds
2 Replies

7. Shell Programming and Scripting

Script to compare file sizes

I need to write a bash script larger X Y that compares the sizes of two specified files X and Y, and reports which file is larger. For example, if X is larger, the output should be "File X is larger", while if Y is larger, the output should be "File Y is larger". If the files are exactly the... (3 Replies)
Discussion started by: julia_21436
3 Replies

8. Shell Programming and Scripting

Using csh / awk / sed to compare database sizes in a txt file

Hello, I have an output file showing database sizes across the 3 environments that I use (LIVE, TEST & DEVELOPMENT). I am trying to write a script that lets me know if the size of a db on one environment is different to its corresponding db on the other environments. Here is an example... (4 Replies)
Discussion started by: stevie_g
4 Replies

9. UNIX for Dummies Questions & Answers

ksh scripting, skip server if asks for password with SSH

Hi, I am running a script that connets to a list of servers with SSH and runs a command but I have some servers that are asking for password (authorized keys is not configured properly). Is there any way to do so that if I get a prompt for password just skip that entry? my script: ... (1 Reply)
Discussion started by: galuzan
1 Replies

10. Shell Programming and Scripting

Ksh: how compare content of a file with an other array

Hi, I created a skript in ksh which generate a file with semicolon as separator, this is an example of the file a created: example content file: hello;AAAA;2014-08-17 hello;BBBB;2014-08-17 hello;CCCC;2014-08-17 I would need to compare the content in of the second column of this file... (3 Replies)
Discussion started by: jmartin
3 Replies
bootparams(4)							   File Formats 						     bootparams(4)

NAME
bootparams - boot parameter data base SYNOPSIS
/etc/bootparams DESCRIPTION
The bootparams file contains a list of client entries that diskless clients use for booting. Diskless booting clients retrieve this infor- mation by issuing requests to a server running the rpc.bootparamd(1M) program. The bootparams file may be used in conjunction with or in place of other sources for the bootparams information. See nsswitch.conf(4). For each client the file contains an entry with the client's name and a list of boot parameter values for that client. Each entry has the form: clientname keyword=value... The first item of each entry is the host name of the diskless client. You can use the asterisk ('*') character as a "wildcard" in place of the client name in a single entry. A wildcard entry applies to all clients for which there is not an entry that specifically names them. In a given entry, the host name or asterisk is followed by one or more whitespace characters and a series of keyword--value pairs separated by whitespace characters. There must not be any whitespace within a keyword--value pair. Each keyword--value pair has the syntax: keyword=value The preceding form breaks out further as: keyword=server:value Where server can be null and value can be a pathname. An example that includes a server is: client1 root=server1:/export/client1/root An example where server is null is: client1 rootopts=:vers2 A minor variation of the keyword=value syntax is used for the domain keyword. Unlike the forms shown above, this syntax does not use a colon. For example: client1 domain=bldg1.workco.com Entries can span multiple lines. Use the backslash ('') character as the last character of a line to continue the entry to the following line. For multiple-line entries, you can split a line only in places where whitespace is allowed. For example, you can use a backslash to split the following entry between the end of the path (root) and the keyword domain: client1 root=server1:/export/client1/root domain=bldg1.workco.com In entries that specify a server, server is the name of the server that will provide the file or filesystem to the diskless client and value is the pathname of the exported file or filesystem on that server. In entries that use the domain keyword, the domain name specified must be the client's domain name. The algorithm for determining a client's domain name is to first check for a domain keyword in the client-specific entry and then in "wildcard" entry. If none is found, the server's domain name is used. For the JumpStart installation of machines that do not have video displays, use the term keyword to identify the terminal type of the boot server. Terminal types are listed in /usr/share/lib/terminfo (see terminfo(4)). An entry with the ns keyword associates a server (a name server) with, instead of a pathname, a specific name service (NIS+, NIS, LDAP, or none) and, if that server is not on a local subnet, the netmask needed to reach it. For example: ns=hoot:nisplus(255.255.255.0) An ns entry forces sysidtool(1M) to use the specified name service. By default, sysidtool uses NIS+ in preference to NIS or LDAP if it can find an NIS+ server for the system's domain on the subnet. An ns entry might be necessary if you are trying to set up a hands-off installa- tion, or if the name server is on a different subnet, which is common with NIS+. If an ns keyword is not used, sysidtool uses broadcast to attempt to bind to either a NIS+, NIS, or LDAP server. If a name server is not on the local subnet, which is possible for NIS+ or LDAP, the bind will fail, automatic configuration of the name service will fail, and an interactive screen is displayed, prompting the user to specify the name service. The ns keyword can be set in add_install_client or by Host Manager. EXAMPLES
Example 1: Sample bootparams Entry Here is an example of an entry in the bootparams file: client1 root=server1:/export/client1/root rootopts=:vers=2 domain=bldg1.workco.com client2 root=server2:/export/client2/root ns=:nis client3 root=server2:/export/client3/root ns=watson: client4 root=server2:/export/client4/root ns=mach:nisplus(255.255.255.0) Example 2: Sample Entry for JumpStart The following is an example of an entry that might be used for the JumpStart installation of diskless clients that do not have displays. mozart root=haydn:/export/install/sparc/os/latest/Solaris_9/boot install=haydn:/export/install/sparc/os/8.1/latest boottype=:in install_config=haydn:/usr/local/share/lib/jump-net ns=otis:nisplus(255.255.255.0) term=:xterms domain=eu.cte.work.com FILES
/etc/bootparams SEE ALSO
rpc.bootparamd(1M), sysidtool(1M), nsswitch.conf(4) NOTES
Solaris diskless clients use the keywords root and rootopts to look up the pathname for the root filesystem and the mount options for the root filesystem, respectively. These are the only keywords meaningful for diskless booting clients. See mount_ufs(1M). SunOS 5.10 22 Jul 2004 bootparams(4)
All times are GMT -4. The time now is 10:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy