473,385 Members | 1,782 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,385 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 2951
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.