Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 6th July 2011
Oko's Avatar
Oko Oko is offline
Rc.conf Instructor
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 1,102
Default AWK passing the argument to system command

I was wondering if somebody could tell me if there is a way to pass argument to a system command in AWK. Namely, let suppose that I want to print calendar for September-November of 2011. I can do that with

#!/usr/bin/awk -f

BEGIN {FS=" "; OFS=""}
        system("cal 8 2011")
        system("cal 9 2011")
        system("cal 10 2011")
        system("cal 11 2011")
However I would like to be able to do something like
#!/usr/bin/awk -f

BEGIN {FS=" "; OFS=""}
{ for (i = 8; i <= 11; i++)
        system("cal $i 2011")
I also tried

#!/usr/bin/awk -f

BEGIN {FS=" "; OFS=""}
{ for (i = 8; i <= 11; i++)
        system("cal"  i "2011")
but no luck.

Anybody knows how to do this?

P.S. I am not interesting in the shell script or anything else. I want to do this with AWK.
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
mount-msdosfs /dev/dao: : Invalid argument harold FreeBSD General 5 12th December 2010 06:59 AM
problem passing /dev/fd/n to programs TerryP Programming 2 15th April 2009 08:24 AM
Mount DVD - invalid argument. maxrussell FreeBSD General 17 7th January 2009 08:46 AM
Scripted sysinstall fails with "Command 'system' failed" PeterSteele FreeBSD Installation and Upgrading 0 13th November 2008 11:31 PM
passing arg from bootloadder to kernel l2fl2f FreeBSD General 16 15th May 2008 12:38 PM

All times are GMT. The time now is 02:15 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick