473,399 Members | 3,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

can't call a shell script from within awk

63
i can execute echo from within awk like so:
Expand|Select|Wrap|Line Numbers
  1. echo asdf jkl asdf \
  2. | awk ' /jkl/ { sub(/jkl/,echo "X(&)") } {print}'
  3. asdf X(jkl) asdf
but if i want to execute another shell script
Expand|Select|Wrap|Line Numbers
  1. cat ~/bin/doit
  2. #!/bin/bash
  3. echo -n KKK
like so:
Expand|Select|Wrap|Line Numbers
  1. echo asdf jkl asdf \
  2. | awk ' /jkl/ { sub(/jkl/,doit) } {print}'
  3. asdf  asdf
it doesnt work.

at least i found that it is not a path related issue, since
Expand|Select|Wrap|Line Numbers
  1. echo asdf jkl asdf \
  2. | awk ' /jkl/ { sub(/jkl/,echo "("ENVIRON["PATH"]")") } {print}'
  3. asdf (/home/peter/bin:/opt/bin:/bin:/sbin:/usr/bin:/usr/sbin) asdf
any ideas how i can make awk execute my ~/bin/doit ?
Jan 13 '12 #1
1 2952
Luuk
1,047 Expert 1GB
use the function 'system(), see man-pages..:'
Expand|Select|Wrap|Line Numbers
  1.        system(cmd-line)      Execute  the command cmd-line, and return the exit status.  (This may not be available on non-POSIX
  2.                              systems.)
  3.  
Mar 31 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tim | last post by:
I have tried to write a php program to execute the shell script,but dont know why it is not successful lei? file: test.php <? system("/home/www/htdocs/ok"); ?> file: ok (permission 755)...
2
by: Juggler | last post by:
Hi, I have a shell script which takes three arguments, how can I call this script from within a C++ program. I am new to C++ programming and not sure how to accomplish this. I tried using...
6
by: ruca | last post by:
Hi, Can I call two script blocks for different languages in my ASP.NET code? I have a button than when clicked it must open a popup window to return some values for two other controls that I...
0
by: GSRao | last post by:
Hi, I am new to DB2 and in a new job and in need of urgent help. Here we have about 100 queries (SQL) that have been manually executed to retrieve totals from different tables and post it to...
1
kamill
by: kamill | last post by:
HOW CAN I CALL PHP SCRIPT WITH CLOSING BROWSER?? I need to run a PHP script (that contains a Mysql Updation query) with the closing of browser. How can i do it?
3
by: telduivel | last post by:
Can someone please help me with this: I have a python script, that at some point calls a linux bash script (.sh). Starting the shell script is the last thing my python script needs to do, so I...
2
by: idorjee | last post by:
hi, can anyone please tell me how to run a shell script in php. i tried the following way, but doesn't work. the file permissions are OK. <? if($_POST){ ...
3
by: Okonita via DBMonster.com | last post by:
Hi all, Working on a little shell script to remove specific records from a flat file. I have scanned a one or two script books and googled for answers but have no success. Can someone show me how...
3
by: gupta24 | last post by:
How can create web page using shell script....... Like web page like winner of the month(given the input) = john type of the prize(given the input)= gold the given page like
2
by: gbprithvi | last post by:
if yes..plz give me an example ... thanku :)
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.