Sponsored Content
Top Forums UNIX for Advanced & Expert Users awk trouble inside another command Post 303037511 by cokedude on Saturday 3rd of August 2019 08:25:29 PM
Old 08-03-2019
Quote:
Originally Posted by jim mcnamara
I've stayed away because I could not get past the dsh -w
AIX dsh and linux dash (sometimes dsh) do not have a -w option. Per manpages for both. What does that do -- dsh -w ?

So I'm not sure what is going on. Plus the whole code design concept seems to me to be based on 'one-liner' thinking. Which is cool but not always maintainable as you are finding out.
It looks like you are trying to kill processes with files open - somewhere special. What OS and shell are you using?
I am using AIX. Normally dsh runs a command against all of your servers in your server list. When you add the -w option to dsh it allows you to select which server you want to run your command on. In my case I want to run my command on server1. I could run my command without the -w option but it would be harder to debug my problem.

I am not very good at using multiple single and double quotes, and escaping. I think that is my issue.
 

10 More Discussions You Might Find Interesting

1. AIX

Trouble formatting egrep command with AWK

Hi, I'm new to scripting and AIX. I'm running the following: lspv | awk '{ print "lspv",$1" | egrep 'PP\|PHYSICAL'; lspv -l",$1 }' Which creates this command: lspv hdisk0 | egrep PP|PHYSICAL; lspv -l hdisk0 lspv hdisk1 | egrep PP|PHYSICAL; lspv -l hdisk1 Troube is, I need the... (2 Replies)
Discussion started by: cruiser
2 Replies

2. Shell Programming and Scripting

Running command inside awk

Hi, I have a awk script to read a CSV file. After reading the values i want to call a executable (nameely call_it) with the values what i read from the scv file. I dont want to use system command inside the awk. Is there any other way to run the executable from the awk script Thanks ... (1 Reply)
Discussion started by: Raghuram.P
1 Replies

3. Shell Programming and Scripting

How to use same variable value inside as well as outside of the awk command?

Hi Jim, The following script is in working state. But i m having one more problem with awk cmd. Could you tell me how to use any variable inside awk or how to take any variable value outside awk. My problem is i want to maintain one property file in which i am declaring variable value into that... (12 Replies)
Discussion started by: Ganesh Khandare
12 Replies

4. Shell Programming and Scripting

Trouble with passing Variable from bash to awk gsub command

Would really appreciate it if someone could point out my mistake in this line of code, i've been staring blankly at it trying everything i can think of some time now and coming up with nothing. #!/bin/bash echo "Enter Username" read Username awk -F: -v var=${Username} '/^var:/... (9 Replies)
Discussion started by: Nostyx
9 Replies

5. Shell Programming and Scripting

Multiple command execution inside awk command during xml parsing

below is the output xml string from some other command and i will be parsing it using awk cat /tmp/alerts.xml <Alert id="10102" name="APP-DS-ds_ha-140018-componentFailure-S" alertDefinitionId="13982" resourceId="11427" ctime="1359453507621" fixed="false" reason="If Event/Log Level(ANY) and... (2 Replies)
Discussion started by: vivek d r
2 Replies

6. Shell Programming and Scripting

Help in using date command inside awk

Hi All, bash-3.2$ autorep -J BOX_NAME% -l0 | grep BOX_NAME| awk -f awkScript.awk sh: -c: line 0: unexpected EOF while looking for matching `"' sh: -c: line 1: syntax error: unexpected end of file BOX_NAME SU 06/21/2013 03:44:03 06/21/2013 07:46:37 0 #My awkfile { ... (3 Replies)
Discussion started by: ddspark
3 Replies

7. Shell Programming and Scripting

Grep command inside awk

Hi, I would like to use grep command inside awk. Here is my requirement below : file.txt col1 col2 col3 col 4 col 5 wrxwrx 124 jun 3 Sensex.EMEA wrxwrx 120 jun 4 Emex.US wrxwrx 130 feb 3 passion.AUS wrxwrx 145 feb 9 lession.AUS wrxwrx 130 feb 5 pass.US wrxwrx 130 feb 8... (5 Replies)
Discussion started by: Balasankar
5 Replies

8. Shell Programming and Scripting

Command in inside awk statement

Hello can you please help me with below script which is meant to delete clients from multiple netbackup policies I want to run a command insdie awk statement apparelnlty this script is not working for me for i in $( cat clients_list) do bppllist -byclient $i | awk... (6 Replies)
Discussion started by: Sara_84
6 Replies

9. Shell Programming and Scripting

Trouble with awk command

Hi, I need to read a string with ; separated using loop one filed by one field and perform some operation. Can you please check and let me know how to print command parameterised. key=phani;ravi;kiran number_of_keys=`echo $key|awk '{print NF}' FS=';'` for (( i = 1; i <= $number_of_keys;... (4 Replies)
Discussion started by: Ravindra Swan
4 Replies

10. Shell Programming and Scripting

Trouble using awk command

Hi, I have 2 .txt pads containing data. I need a script which reads content of one .txt file, performs some operations and calculates a number which is stored in a variable. Now , all the content of another .txt pad should be appended to first .txt pad at pre calculated nth line number. ... (4 Replies)
Discussion started by: Ravindra Swan
4 Replies
KANIF(1)						       kanif TakTuk Wrapper							  KANIF(1)

NAME
kanif - a TakTuk wrapper for cluster management SYNOPSIS
kash|kaget|kaput [-aFHhimqsV] [-f conf-file] [-l login] [-M machines-list] [-n|-w nodes] [-o options] [-p level] [-r command] [-T options] [-t timeout] [-u timeout] [-x nodes] [machines specifications] [command body] DESCRIPTION
kanif is a tool for cluster management and administration. It combines main features of well known cluster management tools such as c3, pdsh and dsh and mimics their syntax. For the effective cluster management it relies on TakTuk, a tool for large scale remote execution deployment. For simple parallel tasks that have to be executed on regular machines such as clusters, TakTuk syntax is too complicated. The goal of kanif is to provide an easier and familiar syntax to cluster administrators while still taking advantage of TakTuk characteristics and features (adaptivity, scalability, portability, autopropagation and informations redirection). To work, kanif needs to find the "taktuk" command (version 3.3 and above) in the user path. The other requirements are the same as TakTuk: it requires, on all the nodes of the cluster, a working Perl interpreter (version 5.8 and above) and a command to log without password (such as "ssh" with proper rsa keys installed). kanif provides three simple commands for clusters administration and management: kash: runs the same command on multiple nodes kaput: broadcasts the copy of files or directories to several nodes kaget: gathers several remote files or directories kanif combines the advantages of several cluster management tools. Its main features can be summarized as follows: o C3-style configuration file for static clusters setups o pdsh-like options such as nodes ranges and timeouts o dshbak-like gathering, sorting and merging of output As with "pdsh", kanif deployment can be monitored and controlled by signals. When kanif receives a SIGINT (usually sent by typing Ctrl-C), it displays a brief summary of its deployment state and commands execution progress. After this first SIGINT, if kanif receives a second signal within one second: o it terminates its execution (cancelling any ongoing task) if this is a SIGINT o it cancels any ongoing connections and start executions on the already deployed nodes if this is a SIGTSTP (usually sent by typing Ctrl-Z) At the end of executions, kanif also reports a quick summary of failures: connections and commands execution. OPTIONS
To help administrators in their task, kanif options syntax is as close as possible to C3/pdsh/dsh well known tools. -a --all Deploys on all nodes of all configured clusters. -f conf-file --file conf-file Uses "conf-file" as configuration file instead of default. Several possibilities are examined for default configuration file, in order: "$HOME/.kanif.conf", "/etc/kanif.conf", "/etc/c3.conf". -F --flat-deployment Deploys all remote execution from the root node (which executes kanif). Useful when remote nodes cannot log on each other. -H --head Deploys only on clusters "head" node (using local interface) for all specified clusters. -h --help Prints a short help text and exits. -i --interactive Asks confirmation before any action. An action is either the execution of one command on all the hosts (default) or the execution of one command on one host (sequential mode, see -s switch). -l login --login login Uses the given "login" to connect to remote hosts. -M machines-list --list machines-list Adds to the remote hosts the names contained in the file named "machines-list". kanif accepts as many -M options as you wish. -m --monitoring Makes kanif more verbose about whats happening during deployment commands execution. -n nodes --nodes nodes Adds the given "nodes" to the deployment. See section "HOSTNAMES SPECIFICATION" for more information about "nodes" syntax. kanif accepts as many -n options as you wish. -o options --remote-opts options Sets additional options to be passed to the remote shell command. -p level --postprocess level Sets the level of output formating made in kanif. The general idea is: the higher the level, the more sorted, merged and human readable the output. Default is 4, differents levels are: 0 No processing at all: raw commands output is printed to stdout and raw commands error is printed to stderr. Connections and executions errors are not reported. 1 Same as 0 except that the name of the host which produced the output is prepended before each line. 2 Same as 1 except that the output is sorted by command (one complete command execution is outputed entirely before another one). Connections and executions errors are summarized at the end to stderr. 3 Same as 2 except that the hostname is printed once, formatted as a title, before its output. 4 Same as 3 except that identical output produced by multiple nodes is printed once with all the hosts summarized in the title. -q --dry-run When this option is given, kanif does nothing and prints its configuration, the remote nodes it would have tried to contact and the TakTuk command that would have been executed. -r command --remote-cmd command Sets the name of the "command" used to contact remote hosts (default is "ssh -o StrictHostKeyChecking=no -o BatchMode=yes"). -s --sequential Each command is executed sequentially on remote hosts (using the order given on the command line as hosts order). -T options --taktuk-options options Allows power users to pass some options to the TakTuk command executed (caution: always include -s which is the default unless you really know what you are doing). -t timeout --timeout timeout Gives a timeout value for connection attempts. At expiration, connection is canceled and deployment on the remote host is aborted. -u timeout --upper-limit timeout Gives a timeout value for commands execution. At expiration the command is killed with a TERM signal. -V --version Prints kanif version and exits. -w -wcoll Synonym to -n. -x nodes --exclude nodes Excludes some nodes from the ones given using -n or -w. Applies to all hosts sets that do not already contain an exclusion part. Does not apply to host given with -M option. ENVIRONMENT
Usually all kanif options can be set by environment variables. The rationale is that boolean options have 0/1 value and environment settings are overridden by command line switches. The name of an environment variable used by kanif is made of the long option name capitalized with dashes replaced by underscores and "KANIF_" prepended (for instance "KANIF_ALL", "KANIF_HEAD", and so on). This rule admits the following exceptions (that have been chosen to mimic C3/dsh behavior): KANIF_CONF Instead of KANIF_FILE for configuration file. KANIF_USER Instead of KANIF_LOGIN for login name. Notice also that the variable KANIF_WCOLL has no meaning to kanif. HOSTNAMES SPECIFICATION
Hostnames given to kanif might be simple machine name or complex hosts lists specifications. In its general form, an hostname is made of an host set and an optional exclusion set separated by a slash. Each of those sets is a comma separated list of host templates. Each of these templates is made of constant parts (characters outside brackets) and optional range parts (characters inside brackets). Each range part is a comma separated list of intervals or single values. Each interval is made of two single values separated by a dash. This is true for all hostnames given to kanif (both with -M or -n/-w options). In other words, the following expressions are valid host specifications: node1 node[19] node[1-3] node[1-3],otherhost/node2 node[1-3,5]part[a-b]/node[3-5]parta,node1partb they respectively expand to: node1 node19 node1 node2 node3 node1 node3 otherhost node1parta node2parta node2partb node3partb node5partb Notice that these list of values are not regular expressions ("node[19]" is "node19" and not "node1, node2, ...., node9"). Intervals are implemented using the perl magical auto increment feature, thus you can use alphanumeric values as interval bounds (see perl documentation, operator ++ for limitations of this auto increment). MACHINES SPECIFICATIONS
With kanif, you can specify the remote nodes on which you want to do some stuff using the command line switches (-n and -x, pdsh/dsh style), using machines specifications (C3 style) or both. Thus, this part of the documentation might be ignored if you do not want to use C3 style nodes management. To use machines specification you must describe your cluster in a configuration file (see -f option and kanif.conf(5)). Machines specifications are nodes intervals taken from clusters defined in this file. A machine specification is an optional cluster name followed by a colon and an optional range. The default cluster is taken if no cluster name is given. All the nodes of the cluster are taken if no range is given. Notice that if none of -n/-w, -M or machine specification is given on the command line, the remote hosts are assumed to be all the nodes of the default cluster. COMMAND BODY
Depending on the name used to invoke it (kash, kaput or kaget), kanif does not perform the same task. Here are its various behavior: kash [options] [command line] Executes the last part of the command line on all the remote hosts. If this last part is empty, enters interactive mode in which kanif waits for command (one per line) on stdin. In interactive mode, just send an EOF character (Ctrl-D) to exit kash. kaput [options] src1 [src2 ...] dest Copies one ore more files or directories to all the remote hosts. The last argument is the path to the destination file or directory on the remote machine. The other arguments are local files or directories to copy. Behavior and limitations are similar to the command cp(1). kaget [options] src1 [src2 ...] dest Download one ore more files or directories from all the remote hosts. The last argument is the path to the destination directory on the local machine. The other arguments are path to files or directories on remote hosts. Each source must be present on all the remote hosts. Sources are copied to the destination directory having the originating host appended to their name. Notice that when using kaget or kaput each file or directory is completely copied before proceeding to the next one. EXAMPLES
When a configuration file exists on the system or is given on the command line (see option -f), remote machines can be specified via clusters names. For instance, the simple execution of the command "ls -l" on all the nodes of the cluster named "megacluster" can be written: kash megacluster: ls -l Intervals can also be given. The following command copies the local .cshrc file to the login directory of a subset of the default cluster and another subset of the "megacluster": kaput :3-6 megacluster:2-5 $HOME/.cshrc . Finally, one can take advantage of the default behavior to gather a file named "results.txt" placed in the "/tmp" directory on all the nodes of the default cluster to the local directory "results": kaget /tmp/results.txt results When a user does not want to write a configuration file or just wants to deploy on some other nodes, it is possible to give remote hosts on the command line: kash -n localhost,supernode uptime This last command will just execute "uptime" on "localhost" and "supernode". Giving intervals and exclusion lists is also possible on the command line. The following command copie the file "/tmp/temporary.txt" to the remote "/tmp" directories of node1 and node5: kaput -n node[1-6] -x node[2-4],node6 /tmp/temporary.txt /tmp Finally, without entering into the details of each option, the final command illustrates the -u option. It executes during 5 seconds a "ping" to "gateway" from 5 nodes: kash -n node[1-2],node[4-6] -u 5 ping gateway BUGS
Missing features: o indirect clusters not supported (see C3 documentation about such clusters) o when there are no machine to deploy and kanif runs in interactive mode, kanif still waits for a command (or eof) before exiting Performance issues: o the algorithm used by kaput is not very efficient for transferring large files. Although the precise limit depends on the machine, it should not scale well above a few hundreds of megabytes. SEE ALSO
taktuk(1), kanif.conf(5) AUTHOR
The author of kanif and current maintainer of the package is Guillaume Huard. Acknowledgements to Lucas Nussbaum for the idea of the name "kanif". COPYRIGHT
kanif is provided under the terms of the GNU General Public License version 2 or later. perl v5.14.2 2012-06-22 KANIF(1)
All times are GMT -4. The time now is 04:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy