Sponsored Content
Full Discussion: awk script
Top Forums Shell Programming and Scripting awk script Post 303004588 by Krrishv on Wednesday 4th of October 2017 11:12:58 PM
Old 10-05-2017
awk script

Hi,

I am trying to write a awk script. Below is the logic.

I want to get the user input and search the user in the end system using API.

It is always missing some escape character in the end. Can you help me with the right script.


Code:
BEGIN {
printf "Enter the name: ";
getline name;
print name;
}
{
command = "curl -v -H \"Authorization: WS 00eWxhTuhoHMBcA\"  -H \"Accept: application/json\"  -H \"Content-Type: application/json\"  -X GET \"https://iam.test.com/api/users?search=profile.user\ eq "\ name ;


Last edited by Scrutinizer; 10-05-2017 at 03:05 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies

2. Shell Programming and Scripting

want to pass parameters to awk script from shell script

Hello, I have this awk script that I want to execute by passing parameters through a shell script. I'm a little confused. This awk script removes duplicates from an input file. Ok, so I have a .sh file called rem_dups.sh #!/usr/bin/sh... (4 Replies)
Discussion started by: script_op2a
4 Replies

3. Shell Programming and Scripting

Call shell script function from awk script

hi everyone i am trying to do this bash> cat abc.sh deepak() { echo Deepak } deepak bash>./abc.sh Deepak so it is giving me write simply i created a func and it worked now i modified it like this way bash> cat abc.sh (2 Replies)
Discussion started by: aishsimplesweet
2 Replies

4. Shell Programming and Scripting

Help: How to convert this bash+awk script in awk script only?

This is the final first release of the dynamic menu generator for pekwm (WM). #!/bin/bash function param_val { awk "/^${1}=/{gsub(/^${1}="'/,""); print; exit}' $2 } echo "Dynamic {" for CF in `ls -c1 /usr/share/applications/*.desktop` do name=$(param_val Name $CF) ... (3 Replies)
Discussion started by: alexscript
3 Replies

5. Shell Programming and Scripting

Passing awk variable argument to a script which is being called inside awk

consider the script below sh /opt/hqe/hqapi1-client-5.0.0/bin/hqapi.sh alert list --host=localhost --port=7443 --user=hqadmin --password=hqadmin --secure=true >/tmp/alerts.xml awk -F'' '{for(i=1;i<=NF;i++){ if($i=="Alert id") { if(id!="") if(dt!=""){ cmd="sh someScript.sh... (2 Replies)
Discussion started by: vivek d r
2 Replies

6. Shell Programming and Scripting

Calling shell script within awk script throws error

I am getting the following error while passing parameter to a shell script called within awk script. Any idea what's causing this issue and how to ix it ? Thanks sh: -c: line 0: syntax error near unexpected token `newline' sh: -c: line 0: `./billdatecalc.sh ... (10 Replies)
Discussion started by: Sudhakar333
10 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. UNIX for Dummies Questions & Answers

Passing shell script parameter value to awk command in side the script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. 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 |... (1 Reply)
Discussion started by: Sarita Behera
1 Replies

9. Shell Programming and Scripting

awk script to call another script based on second column entry

Hi I have a text file (Input.txt) with two column entries separated by tab as given below: aaa str1 bbb str2 cccccc str3 dddd str4 eee str3 ssss str2 sdf str3 hhh str1 fff str2 ccc str3 ..... ..... ..... (1 Reply)
Discussion started by: my_Perl
1 Replies

10. UNIX for Beginners Questions & Answers

Shell script to call and sort awk script and output

I'm trying to create a shell script that takes a awk script that I wrote and a filename as an argument. I was able to get that done but I'm having trouble figuring out how to keep the header of the output at the top but sort the rest of the rows alphabetically. This is what I have now but it is... (1 Reply)
Discussion started by: Eric7giants
1 Replies
Web::Simple::Application(3pm)				User Contributed Perl Documentation			     Web::Simple::Application(3pm)

NAME
Web::Simple::Application - A base class for your Web-Simple application DESCRIPTION
This is a base class for your Web::Simple application. You probably don't need to construct this class yourself, since Web::Simple does the 'heavy lifting' for you in that regards. METHODS
This class exposes the following public methods. default_config Merges with the "config" initializer to provide configuration information for your application. For example: sub default_config { ( title => 'Bloggery', posts_dir => $FindBin::Bin.'/posts', ); } Now, the "config" attribute of $self will be set to a HashRef containing keys 'title' and 'posts_dir'. The keys from default_config are merged into any config supplied, so if you construct your application like: MyWebSimpleApp::Web->new( config => { title => 'Spoon', environment => 'dev' } ) then "config" will contain: { title => 'Spoon', posts_dir => '/path/to/myapp/posts', environment => 'dev' } run_if_script The run_if_script method is designed to be used at the end of the script or .pm file where your application class is defined - for example: ## my_web_simple_app.pl #!/usr/bin/env perl use Web::Simple 'HelloWorld'; { package HelloWorld; sub dispatch_request { sub (GET) { [ 200, [ 'Content-type', 'text/plain' ], [ 'Hello world!' ] ] }, sub () { [ 405, [ 'Content-type', 'text/plain' ], [ 'Method not allowed' ] ] } } } HelloWorld->run_if_script; This returns a true value, so your file is now valid as a module - so require 'my_web_simple_app.pl'; my $hw = HelloWorld->new; will work fine (and you can rename it to lib/HelloWorld.pm later to make it a real use-able module). However, it detects if it's being run as a script (via testing $0) and if so attempts to do the right thing. If run under a CGI environment, your application will execute as a CGI. If run under a FastCGI environment, your application will execute as a FastCGI process (this works both for dynamic shared-hosting-style FastCGI and for apache FastCgiServer style setups). If run from the commandline with a URL path, it runs a GET request against that path - $ perl -Ilib examples/hello-world/hello-world.cgi / 200 OK Content-Type: text/plain Hello world! You can also provide a method name - $ perl -Ilib examples/hello-world/hello-world.cgi POST / 405 Method Not Allowed Content-Type: text/plain Method not allowed For a POST or PUT request, pairs on the command line will be treated as form variables. For any request, pairs on the command line ending in : are treated as headers, and 'Content:' will set the request body - $ ./myapp POST / Accept: text/html form_field_name form_field_value $ ./myapp POST / Content-Type: text/json Content: '{ "json": "here" }' The body of the response is sent to STDOUT and the headers to STDERR, so $ ./myapp GET / >index.html will generally do the right thing. Additionally, you can treat the file as though it were a standard PSGI application file (*.psgi). For example you can start up up with "plackup" plackup my_web_simple_app.pl or "starman" starman my_web_simple_app.pl to_psgi_app This method is called by "run_if_script" to create the PSGI app coderef for use via Plack and plackup. If you want to globally add middleware, you can override this method: use Web::Simple 'HelloWorld'; use Plack::Builder; { package HelloWorld; around 'to_psgi_app', sub { my ($orig, $self) = (shift, shift); my $app = $self->$orig(@_); builder { enable ...; ## whatever middleware you want $app; }; }; } This method can also be used to mount a Web::Simple application within a separate "*.psgi" file - use strictures 1; use Plack::Builder; use WSApp; use AnotherWSApp; builder { mount '/' => WSApp->to_psgi_app; mount '/another' => AnotherWSApp->to_psgi_app; }; This method can be called as a class method, in which case it implicitly calls ->new, or as an object method ... in which case it doesn't. run Used for running your application under stand-alone CGI and FCGI modes. I should document this more extensively but run_if_script will call it when you need it, so don't worry about it too much. run_test_request my $res = $app->run_test_request(GET => '/' => %headers); my $res = $app->run_test_request(POST => '/' => %headers_or_form); my $res = $app->run_test_request($http_request); Accepts either an HTTP::Request object or ($method, $path) and runs that request against the application, returning an HTTP::Response object. If the HTTP method is POST or PUT, then a series of pairs can be passed after this to create a form style message body. If you need to test an upload, then create an HTTP::Request object by hand or use the "POST" subroutine provided by HTTP::Request::Common. If pairs are passed where the key ends in :, it is instead treated as a headers, so: my $res = $app->run_test_request( POST => '/', 'Accept:' => 'text/html', some_form_key => 'value' ); will do what you expect. You can also pass a special key of Content: to set the request body: my $res = $app->run_test_request( POST => '/', 'Content-Type:' => 'text/json', 'Content:' => '{ "json": "here" }', ); AUTHORS
See Web::Simple for authors. COPYRIGHT AND LICENSE
See Web::Simple for the copyright and license. perl v5.14.2 2012-05-11 Web::Simple::Application(3pm)
All times are GMT -4. The time now is 05:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy