escapes getting into program

Oct 18, 2008
329
2
Greetings --

I am trying to tun gawk and getting a error --

the awk cmd is

awk `{ print $1}`

I used the ` char since the jpsoft doc note that the contents are pass
to the program as-is, but gawk generate an error message that ` is
invalid -- how is the ` getting into the gawk program
 
May 20, 2008
3,515
4
Elkridge, MD, USA
fpefpe wrote:
| Greetings --
|
| I am trying to tun gawk and getting a error --
|
| the awk cmd is
|
| awk `{ print $1}`
|
| I used the ` char since the jpsoft doc note that the contents are
| pass
| to the program as-is, but gawk generate an error message that ` is
| invalid -- how is the ` getting into the gawk program

Simple - the whole argument, include the ` character, is passed on. Unless
the command line includes one of the special characters that have
syntactical meaning to TCC you do not need any form of quoting.
--
HTH, Steve
 

samintz

Scott Mintz
May 20, 2008
1,488
15
Solon, OH, USA
I don't know what you're trying to accomplish. But this works for me:

awk -- "{ print $1 }"

awk -- "BEGIN { print \"Hello world\" }"

-Scott


fpefpe <> wrote on 05/04/2009 07:45:31 PM:


> Greetings --
>
> I am trying to tun gawk and getting a error --
>
> the awk cmd is
>
> awk `{ print $1}`
>
> I used the ` char since the jpsoft doc note that the contents are pass
> to the program as-is, but gawk generate an error message that ` is
> invalid -- how is the ` getting into the gawk program
>
>
>
>
 
May 20, 2008
11,285
95
Syracuse, NY, USA
On Mon, 04 May 2009 18:45:59 -0500, fpefpe <> wrote:

|the awk cmd is
|
|awk `{ print $1}`
|
|I used the ` char since the jpsoft doc note that the contents are pass
|to the program as-is, but gawk generate an error message that ` is
|invalid -- how is the ` getting into the gawk program

I can't explain it but I doubt they're being passed to awk (unless awk is
somehow special). TCC just doesn't do that. For example:

v:\> u:\EchoArgs.exe `{ print $1 }`
u:\EchoArgs.exe
{
print
$1
}

Have you perhaps used SETDOS to disable the back-quote?
--
- Vince
 
May 20, 2008
3,515
4
Elkridge, MD, USA
vefatica wrote:
| I can't explain it but I doubt they're being passed to awk (unless
| awk is somehow special). TCC just doesn't do that. For example:
|
| v:\> u:\EchoArgs.exe `{ print $1 }`
| u:\EchoArgs.exe
| {
| print
| $1
| }

That's not my observation. My 15-year old ANSI C program (text mode, of
course) argparse.exe reports with equivalent command line (identical command
tail):

Command tail: '{ print $1 }'
0 "C:\UTIL\ARGPARSE.EXE"
1 "'{"
2 "print"
3 "$1"
4 "}'"

Note that the backticks are part of the command tail and of the 1st and 4th
argument. All this with SETDOS reporting EXPANSION=0, i.e., nothing
disabled.
--
Steve
 
Steve Fabian wrote:

>
> vefatica wrote:
> | I can't explain it but I doubt they're being passed to awk (unless
> | awk is somehow special). TCC just doesn't do that. For example:
> |
> | v:\> u:\EchoArgs.exe `{ print $1 }`
> | u:\EchoArgs.exe
> | {
> | print
> | $1
> | }
>
> That's not my observation. My 15-year old ANSI C program (text mode, of
> course) argparse.exe reports with equivalent command line (identical
> command
> tail):
>
> Command tail: '{ print $1 }'
> 0 "C:\UTIL\ARGPARSE.EXE"
> 1 "'{"
> 2 "print"
> 3 "$1"
> 4 "}'"
>
> Note that the backticks are part of the command tail and of the 1st and
> 4th
> argument. All this with SETDOS reporting EXPANSION=0, i.e., nothing
> disabled.

But those are forward ticks, not backticks!

--
Howard
 
May 20, 2008
11,285
95
Syracuse, NY, USA
On Mon, 04 May 2009 20:15:55 -0500, Steve Fábián <> wrote:

|That's not my observation. My 15-year old ANSI C program (text mode, of
|course) argparse.exe reports with equivalent command line (identical command
|tail):
|
|Command tail: '{ print $1 }'
|0 "C:\UTIL\ARGPARSE.EXE"
|1 "'{"
|2 "print"
|3 "$1"
|4 "}'"
|
|Note that the backticks are part of the command tail and of the 1st and 4th
|argument. All this with SETDOS reporting EXPANSION=0, i.e., nothing
|disabled.

How can that be? 4NT/TCC never passed on back-quotes (to my knowledge). Here's
another test, using my 5-minute old test.exe:

g:\projects\test\release> type ..\test.cpp
#include <windows.h>
#include <stdio.h>

INT wmain ( INT argc, WCHAR **argv )
{
WCHAR *pszCommandLine = GetCommandLineW();
wprintf(L"%s\n", pszCommandLine);
return 0;
}
g:\projects\test\release> test.exe `{ foo }`
test.exe { foo }
--
- Vince
 
Oct 18, 2008
329
2
On Mon, 04 May 2009 18:45:59 -0500, fpefpe <> wrote:

|the awk cmd is
|
|awk `{ print $1}`
|
|I used the ` char since the jpsoft doc note that the contents are pass
|to the program as-is, but gawk generate an error message that ` is
|invalid -- how is the ` getting into the gawk program

I can't explain it but I doubt they're being passed to awk (unless awk is
somehow special). TCC just doesn't do that. For example:

v:\> u:\EchoArgs.exe `{ print $1 }`
u:\EchoArgs.exe
{
print
$1
}

Have you perhaps used SETDOS to disable the back-quote?
--
- Vince

Greetings --

No, I don't think that I turned of quoting with setdos.
I was trying to run gawk command using the back tick ` prevent the
command line from being process. I kept getting errors, so I wrote a simple C
program to echo the contents of the argv array passed into the program. In
addition, I also called the win/api "GetComamndLine" to get the complete command
line

If I am reading the doc correctly, the ` character when used to start and end an
argument, should be striped way and the text between them passed to the program
in the same way the ' work for unix shell.
From my simple program, that does not seem to be the case -- Did I miss read
the doc?

Thanks

Frank Esposito

Sample program output -->

Cmd line {args this is a `test`}
Args Count: 5

Argument(0) is {args}
Argument(1) is {this}
Argument(2) is {is}
Argument(3) is {a}
Argument(4) is {`test`}
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,423
85
Albuquerque, NM
prospero.unm.edu
Greetings --

No, I don't think that I turned of quoting with setdos.
I was trying to run gawk command using the back tick ` prevent the
command line from being process. I kept getting errors, so I wrote a simple C program to echo the contents of the argv array passed into the program. In addition, I also called the win/api "GetComamndLine" to get the complete command line

If I am reading the doc correctly, the ` character when used to start and end an argument, should be striped way and the text between them passed to the program in the same way the ' work for unix shell.
From my simple program, that does not seem to be the case -- Did I miss read the doc?

I don't know what's going on on your system, but on mine the backquotes definitely are stripped before a command is executed. What do you see when you do e.g.

Code:
echo `foo`

What does VER /R report?
 
May 20, 2008
11,285
95
Syracuse, NY, USA
On Fri, 15 May 2009 17:18:01 -0500, fpefpe <> wrote:

|Sample program output -->
|
|Cmd line {args this is a `test`}
|Args Count: 5
|
|Argument(0) is {args}
|Argument(1) is {this}
|Argument(2) is {is}
|Argument(3) is {a}
|Argument(4) is {`test`}

That's contrary to what I see (and contrary to the way 4NT/TCC has always
worked):

v:\> args this is a `test`
args
this
is
a
test

Are you talking about the backtick which is on the key just to the left of the
"1" key?
--
- Vince
 
May 31, 2008
382
2
Greetings --

I am trying to tun gawk and getting a error --

the awk cmd is

awk `{ print $1}`

I used the ` char since the jpsoft doc note that the contents are pass
to the program as-is, but gawk generate an error message that ` is
invalid -- how is the ` getting into the gawk program

I use gawk, but I assume that it's the same for awk.
First of all, use double quotes around your inline script:
awk "{ print $1}"
this works for me. The confusion starts when you need to use double quotes also inside the script. You need to use 3 double quotes to escape one single double quote in a gawk inline script, so:

awk "{ print """dollar1="""$1}"
this also works for me. Happy (g)awking

Years ago I read a post which stated that backtick processing is broken in awk for Windows. Now, I don't know what that really means, if awk actually makes up the backticks or what, but anyway I found the magic trick with the 3 double quotes and I'm happy.
 
Similar threads
Thread starter Title Forum Replies Date
C history is getting deleted under unknown circumstances Support 9
MikeBaas V19 getting non-responsive Support 1
WadeHatler Just started getting a message about Cloud Storage every time I start TCC 19 Support 3
Jay Sage Getting Quote Characters into a Toolbar Tab Support 12
M How to? List path getting short file and directory names... Support 10
mfarah How to? Getting pdir to display relative paths. Support 2
M Why is this function getting these results in these circumstances? Support 6
R Command history getting reloaded Support 16
M Programmatically getting the console width in character Support 18
H Behavior change re piping a string to a Java program Support 1
S How to? Runs start /w in invisible mode OR run program after exit of another one Support 3
W Starting program for word to pdf conversion (difference cmd and tcc) Support 13
MickeyF Why doesn't my python program get executed without specifying its path? Support 2
R How to? START program as top window? Support 2
M "less" program that works in TC 18 Support 12
MickeyF running program from script and (not) returning to script Support 12
C INSTALLED returnes same program multiple times Support 14
C Recommend a Print program Support 1
MickeyF running a program from cmdline versus in batch file Support 1
C tcmd.ini not loading from program dir? Support 5
Joe Caverly Determine if program started from command prompt Support 2
C WAD TCC: (Sys) C:\Program Files\JPSoft\TCMD17\tcc.exe is not a valid Win32 application. Support 6
C Win7 Program Data.... Support 2
M How to? Start a program on log on elevated abovenormal Support 5
MickeyF how to determine which program will execute a file Support 10
D New 64-bit install goes to Program Files x86 Support 3
M How is this program found? Support 9
A How to? Run a TCC command from external program Support 2
C "Program Files" .vs. "Program Files (x86)" Support 2
BobK "do you want to allow the following program to make changes to this computer" Support 3
M How to? Get the return code from an external program... Support 8
C start /wait /pgm "program name" ^ ketstack n/w Support 3
L File association: System cannot find the associated program Support 30
vefatica c:\program? Support 4
D Start program without waiting and redirect output Support 6
nikbackm Alias - launch external program - batch file Support 16
Joe Caverly Program gives error if %_row > 25 Support 0
dcantor Program abort with tab bar Support 2
M Invoking a DOS command within a C++ program Support 1
J 4NT Error when running 'system' from a program to execute a .BTM Support 3
C start/tab of a GUI program hangs TCMD Support 6

Similar threads