Sponsored Content
Top Forums Shell Programming and Scripting How can I pass arguments to system command in a awk script? Post 302885378 by solaris21 on Saturday 25th of January 2014 01:18:01 PM
Old 01-25-2014
thanks for your help Akshay Hegde Smilie

Code:
function Cmd(cmde,result){
                              while ((cmde | getline line) > 0)
                                  {
                                      result = result (result=="" ? "" : "\n")line
                                  }
                              close(cmde)
                              return result
                         }

function convierte()
{
 cadena=$0;
 longitud=length(cadena);
 pos=1;
 byte=substr(cadena,pos,2);
 resul=Cmd("grep "byte"  mapeo.txt|awk '{print $2}'");
 print resul;
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

can I pass awk variable to system command?

I wanna use a system function to deal with several data. So I use awk variable FILENAME to transfer the file directory to system command, but it does not work. I use a shell function "out_function" to deal with data and save the result in another directory with the same file name. How can I... (2 Replies)
Discussion started by: zhynxn
2 Replies

2. Shell Programming and Scripting

need help to pass arguments in script

Hi, I have a my script here-- print "The Perl Script does the User health check and system health check...\n"; print "---------------------------------------------------------------------\n"; # use strict; my($OS); $OS = $^O; # need to test @ARGV before GetOptions shifts it if (@ARGV... (1 Reply)
Discussion started by: namishtiwari
1 Replies

3. Shell Programming and Scripting

How do we pass multiple arguments into awk

How do we pass multiple arguments into awk : name=john age=12 now i have to pass both age and name into awk.. how to do it? like : awk -v var=... (4 Replies)
Discussion started by: abhinav192
4 Replies

4. Shell Programming and Scripting

Pass command line arguments to awk

I am trying to pass max as a sommand line argument when I call awk. Made the modification in the BEGIN but it is not working I'm getting an error as below: awk: txsrx.awk:82: (FILENAME=jcd.tx FNR=4161) fatal: cannot open file `40' for reading (No such file or directory) Somehow it... (2 Replies)
Discussion started by: kristinu
2 Replies

5. Shell Programming and Scripting

How can i pass 2 command line arguments with a range between them

Hi, I am writting a script. i am not sure what i am trying to do is possible or not. thats why asking the best of the best. the script i want to write will recieve as input parameters 2 different options. as in MODE 1 -- start_date / end_date (2 dates has 2 go at a time MODE 2... (2 Replies)
Discussion started by: dazdseg
2 Replies

6. Programming

How to pass the command line arguments to the shell script in c language?

hi, I am new in the shell script, and c programming with linux. I am looking to pass the arguments in c program that should be executed by the shell script. e.g. #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv) { int i; for (i=1;i<argc; i++) { ... (2 Replies)
Discussion started by: sharlin
2 Replies

7. Post Here to Contact Site Administrators and Moderators

Unable to pass shell script parameter value to awk command in side the same script

Variable I have in my shell script diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk -F'~' ''$2 == "$id"' {print $0}' > $new I could see value of $id is not passing to the awk... (0 Replies)
Discussion started by: Ashunayak
0 Replies

8. Shell Programming and Scripting

Need to pass shell arguments into Nawk/awk

Hi, I am in critical need of help, Thanks a ton for your help. I need to know how to pass the shell argument into nawk code in AIX. so that my file gets passed into that awk script and it can execute it part. To be detail, i have more than 100 files and in those files a particular field... (6 Replies)
Discussion started by: Selva_2507
6 Replies

9. Shell Programming and Scripting

How to pass command line arguments to awk program?

#!/bin/awk -f BEGIN { FS=":"; } { if ( $7 == "" ) { print $1 ": no password!"; } } I want to execute this program for a particular user to check for his password from the file /etc/passwd (as the input file) and the user details to be given... (1 Reply)
Discussion started by: sri.phani
1 Replies

10. Shell Programming and Scripting

Pass Arguments to Command from Shell Script

Hi all, I am working on a project, in which I have to connect to Bluetooth low energy device. I am able to connect and do data transfer from command line. But I want to do from script Here is my script #!/bin/bash #sudo hcitool -i hci0 lescan sleep 1 sudo hcitool -i hci0 lecc --random... (8 Replies)
Discussion started by: nithin@embdes
8 Replies
Net::Cmd(3pm)						 Perl Programmers Reference Guide					     Net::Cmd(3pm)

NAME
Net::Cmd - Network Command class (as used by FTP, SMTP etc) SYNOPSIS
use Net::Cmd; @ISA = qw(Net::Cmd); DESCRIPTION
"Net::Cmd" is a collection of methods that can be inherited by a sub class of "IO::Handle". These methods implement the functionality required for a command based protocol, for example FTP and SMTP. USER METHODS
These methods provide a user interface to the "Net::Cmd" object. debug ( VALUE ) Set the level of debug information for this object. If "VALUE" is not given then the current state is returned. Otherwise the state is changed to "VALUE" and the previous state returned. Different packages may implement different levels of debug but a non-zero value results in copies of all commands and responses also being sent to STDERR. If "VALUE" is "undef" then the debug level will be set to the default debug level for the class. This method can also be called as a static method to set/get the default debug level for a given class. message () Returns the text message returned from the last command code () Returns the 3-digit code from the last command. If a command is pending then the value 0 is returned ok () Returns non-zero if the last code value was greater than zero and less than 400. This holds true for most command servers. Servers where this does not hold may override this method. status () Returns the most significant digit of the current status code. If a command is pending then "CMD_PENDING" is returned. datasend ( DATA ) Send data to the remote server, converting LF to CRLF. Any line starting with a '.' will be prefixed with another '.'. "DATA" may be an array or a reference to an array. dataend () End the sending of data to the remote server. This is done by ensuring that the data already sent ends with CRLF then sending '.CRLF' to end the transmission. Once this data has been sent "dataend" calls "response" and returns true if "response" returns CMD_OK. CLASS METHODS
These methods are not intended to be called by the user, but used or over-ridden by a sub-class of "Net::Cmd" debug_print ( DIR, TEXT ) Print debugging information. "DIR" denotes the direction true being data being sent to the server. Calls "debug_text" before printing to STDERR. debug_text ( TEXT ) This method is called to print debugging information. TEXT is the text being sent. The method should return the text to be printed This is primarily meant for the use of modules such as FTP where passwords are sent, but we do not want to display them in the debug- ging information. command ( CMD [, ARGS, ... ]) Send a command to the command server. All arguments a first joined with a space character and CRLF is appended, this string is then sent to the command server. Returns undef upon failure unsupported () Sets the status code to 580 and the response text to 'Unsupported command'. Returns zero. response () Obtain a response from the server. Upon success the most significant digit of the status code is returned. Upon failure, timeout etc., undef is returned. parse_response ( TEXT ) This method is called by "response" as a method with one argument. It should return an array of 2 values, the 3-digit status code and a flag which is true when this is part of a multi-line response and this line is not the list. getline () Retrieve one line, delimited by CRLF, from the remote server. Returns undef upon failure. NOTE: If you do use this method for any reason, please remember to add some "debug_print" calls into your method. ungetline ( TEXT ) Unget a line of text from the server. read_until_dot () Read data from the remote server until a line consisting of a single '.'. Any lines starting with '..' will have one of the '.'s removed. Returns a reference to a list containing the lines, or undef upon failure. tied_fh () Returns a filehandle tied to the Net::Cmd object. After issuing a command, you may read from this filehandle using read() or <>. The filehandle will return EOF when the final dot is encountered. Similarly, you may write to the filehandle in order to send data to the server after issuing a commmand that expects data to be written. See the Net::POP3 and Net::SMTP modules for examples of this. EXPORTS
"Net::Cmd" exports six subroutines, five of these, "CMD_INFO", "CMD_OK", "CMD_MORE", "CMD_REJECT" and "CMD_ERROR", correspond to possible results of "response" and "status". The sixth is "CMD_PENDING". AUTHOR
Graham Barr <gbarr@pobox.com> COPYRIGHT
Copyright (c) 1995-1997 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. $Id: //depot/libnet/Net/Cmd.pm#28 $ perl v5.8.0 2002-06-01 Net::Cmd(3pm)
All times are GMT -4. The time now is 01:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy