Re: [Freedos-user] Need help ... calling COMMAND.COM from C

2006-09-18 Thread Arkady V.Belousov
Hi!

16-Сен-2006 08:43 [EMAIL PROTECTED] (Marton) wrote to
freedos-user@lists.sourceforge.net:

M Many thanks for the suggestions but instead of doing stuff in my code...
M couldn't we somehow add a delay to FreeCOM before it exits (when called with
M /c) so everything gets flushed and it works for everyone?

 Trouble not in delay for flush, trouble that (old) FreeCOM was buggy.
Current FreeCOM deals with /c option and redirection fine.

M Under command.com
M everything works as-is and it is a crime to patch my code instead of doing a
M general solution...

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user


Re: [Freedos-user] Need help ... calling COMMAND.COM from C

2006-09-18 Thread Blair Campbell
That would be the edition.

On 9/18/06, Arkady V.Belousov [EMAIL PROTECTED] wrote:
 Hi!

 18-Сен-2006 04:44 [EMAIL PROTECTED] (Marton) wrote to
 freedos-user@lists.sourceforge.net:

 M With current you mean 1.0, or the latest build? 'cause I tried 1.0
 without
 M luck...
   Trouble not in delay for flush, trouble that (old) FreeCOM was
  buggy.
  Current FreeCOM deals with /c option and redirection fine.

  Current - command.com, available from CVS (92787 bytes, FreeCom
 version 0.84-pre2 XMS_Swap [Aug 28 2006 00:29:00]). I don't know, which
 edition was included into FreeDOS 1.0 distributive.

 -
 Using Tomcat but need to do more? Need to support web services, security?
 Get stuff done quickly with pre-integrated technology to make your job
 easier
 Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
 http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
 ___
 Freedos-user mailing list
 Freedos-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/freedos-user



-- 
Fall is my favorite season in Los Angeles, watching the birds change
color and fall from the trees.
   David Letterman (1947 - )

See ya
-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user


Re: [Freedos-user] Need help ... calling COMMAND.COM from C

2006-09-18 Thread Arkady V.Belousov
Hi!

18-Сен-2006 11:21 [EMAIL PROTECTED] (Marton) wrote to
freedos-user@lists.sourceforge.net:

M I tried that exact version, when I type ver I get FreeCom version
M 0.84-pre2 XMS_Swap [Aug 28 2006 00:29:00]... and the issue still
M happens...
 Current FreeCOM deals with /c option and redirection fine.
  Current - command.com, available from CVS (92787 bytes, FreeCom
 version 0.84-pre2 XMS_Swap [Aug 28 2006 00:29:00]). I don't know, which
 edition was included into FreeDOS 1.0 distributive.

 Ok, then may you present test case? If you have source, which not
works, give us this source (and all related files and build batch and make
files), so we may try to reproduce your trouble. Of course, try to minimize
test case (minimal source, minimal batch files to compile).

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user


Re: [Freedos-user] Need help ... calling COMMAND.COM from C

2006-09-18 Thread Marton

Absolutely, the function is simple... just to see if two directories that
should have the same contents changed. Here it goes (hope it indents well):

int checkdir(void) {
int i, filesize = 0;
FILE *fp, *fp2;

system(dir c:\\data\\base1 c:\\data.dir);
fp = fopen(c:\\data.dir,r);
fp2 = fopen(c:\\dataorig.dir,r);
fseek(fp, 0, SEEK_END);
filesize = ftell(fp);
fseek(fp2, 0, SEEK_END);
if(filesize != ftell(fp2))
  filesize = -1;
rewind(fp); rewind(fp2);

for(i=0;ifilesize;i++)
{
  int file1data = 0, file2data = 0;
  fread(file1data,1,1,fp);
  fread(file2data,1,1,fp2);
  if(file1data != file2data)
break;
}

if(i != filesize)
  return 1;
else
  return 0;

fclose(fp);
fclose(fp2);
remove(c:\\data.dir);
remove(c:\\dataorig.dir);
  }
}

This always returns 1 because the file data.dir gets cut so the compare with
dataorig.dir always fails.

Thanks!!

Marton


Arkady V.Belousov wrote:
 
 Hi!
 
 18-Сен-2006 11:21 [EMAIL PROTECTED] (Marton) wrote to
 freedos-user@lists.sourceforge.net:
 
 M I tried that exact version, when I type ver I get FreeCom version
 M 0.84-pre2 XMS_Swap [Aug 28 2006 00:29:00]... and the issue still
 M happens...
 Current FreeCOM deals with /c option and redirection fine.
  Current - command.com, available from CVS (92787 bytes, FreeCom
 version 0.84-pre2 XMS_Swap [Aug 28 2006 00:29:00]). I don't know, which
 edition was included into FreeDOS 1.0 distributive.
 
  Ok, then may you present test case? If you have source, which not
 works, give us this source (and all related files and build batch and make
 files), so we may try to reproduce your trouble. Of course, try to
 minimize
 test case (minimal source, minimal batch files to compile).
 
 -
 Take Surveys. Earn Cash. Influence the Future of IT
 Join SourceForge.net's Techsay panel and you'll get the chance to share
 your
 opinions on IT  business topics through brief surveys -- and earn cash
 http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
 ___
 Freedos-user mailing list
 Freedos-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/freedos-user
 
 

-- 
View this message in context: 
http://www.nabble.com/Need-help-...-calling-COMMAND.COM-from-C-tf2281583.html#a6378774
Sent from the FreeDOS - User mailing list archive at Nabble.com.


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user


Re: [Freedos-user] Need help ... calling COMMAND.COM from C

2006-09-18 Thread Arkady V.Belousov
Hi!

18-Сен-2006 15:29 [EMAIL PROTECTED] (Marton) wrote to
freedos-user@lists.sourceforge.net:

M Absolutely, the function is simple... just to see if two directories that
M should have the same contents changed. Here it goes (hope it indents well):
M int checkdir(void) {
[...]
M system(dir c:\\data\\base1 c:\\data.dir);

 This source is incomplete and contains bugs, which makes it
incompilable, but this is unimportant - now I may reproduce the bug even
without extra program:

command/c ver
FreeCom version 0.84-pre2 XMS_Swap [Aug 28 2006 00:29:00]
command/c dir test
TEST 0  19.09.06  2:55
command/c dir test
command/c dir test
TEST   525  19.09.06  2:56
command/c dir test test
command/c dir test
TEST 0  19.09.06  2:56

So, something really wrong, when cmd (dir above) have arguments and output
is redirected.

 I will try to fix this later, when process patches, which accept Blair.

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user


Re: [Freedos-user] Need help ... calling COMMAND.COM from C

2006-09-18 Thread Marton

Sounds great, Arkady. I'm glad my code at least helped to see the bug. Please
let me know if/when you fix it so I try it :)

Thanks!!
Marton


Arkady V.Belousov wrote:
 
 Hi!
 
 18-Сен-2006 15:29 [EMAIL PROTECTED] (Marton) wrote to
 freedos-user@lists.sourceforge.net:
 
 M Absolutely, the function is simple... just to see if two directories
 that
 M should have the same contents changed. Here it goes (hope it indents
 well):
 M int checkdir(void) {
 [...]
 M system(dir c:\\data\\base1 c:\\data.dir);
 
  This source is incomplete and contains bugs, which makes it
 incompilable, but this is unimportant - now I may reproduce the bug even
 without extra program:
 
command/c ver
 FreeCom version 0.84-pre2 XMS_Swap [Aug 28 2006 00:29:00]
command/c dir test
 TEST 0  19.09.06  2:55
command/c dir test
command/c dir test
 TEST   525  19.09.06  2:56
command/c dir test test
command/c dir test
 TEST 0  19.09.06  2:56
 
 So, something really wrong, when cmd (dir above) have arguments and
 output
 is redirected.
 
  I will try to fix this later, when process patches, which accept
 Blair.
 
 -
 Take Surveys. Earn Cash. Influence the Future of IT
 Join SourceForge.net's Techsay panel and you'll get the chance to share
 your
 opinions on IT  business topics through brief surveys -- and earn cash
 http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
 ___
 Freedos-user mailing list
 Freedos-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/freedos-user
 
 

-- 
View this message in context: 
http://www.nabble.com/Need-help-...-calling-COMMAND.COM-from-C-tf2281583.html#a6379733
Sent from the FreeDOS - User mailing list archive at Nabble.com.


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user


Re: [Freedos-user] Need help ... calling COMMAND.COM from C

2006-09-17 Thread Marton

Many thanks for the suggestions but instead of doing stuff in my code...
couldn't we somehow add a delay to FreeCOM before it exits (when called with
/c) so everything gets flushed and it works for everyone? Under command.com
everything works as-is and it is a crime to patch my code instead of doing a
general solution...

Thanks again,
Marton
-- 
View this message in context: 
http://www.nabble.com/Need-help-...-calling-COMMAND.COM-from-C-tf2281583.html#a6341044
Sent from the FreeDOS - User forum at Nabble.com.


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user


[Freedos-user] Need help ... calling COMMAND.COM from C

2006-09-16 Thread Johnson Lam
Hi,

Please help Marton (marton=at=argentina.com), he stuck with a C
program calling COMMAND.COM:


Now that I moved onto my next step on my project, another issue
arised...
If I run this:

TestDir.bat:
dir /b c:\testdir d:\dirout.put

The file dirout.put has the directory output...

BUT, if I do it this way:

TestDir2.bat:
command /c dir /b c:\testdir d:\dirout.put

The file dirout.put has the directory output but CUT... it never
reaches the end of the output, it just cuts...

Tried with many command coms and kernel versions...

I really need to do it that way because I'm using the system()
function on my C program and it runs command /c with what to run as
an argument.

Any ideas on that?

Kind regards,
Marton


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user


Re: [Freedos-user] Need help ... calling COMMAND.COM from C

2006-09-16 Thread Blair Campbell
Hi.  It almost sounds to me like the destination file isn't getting
flushed to the disk.  I would recommend doing the recirection
internally in the C program, and then you have direct control of the
file.  A simple close(1); open(blah, O_WRONLY); /* system() stuff
here: */ blah blah blah close(1); open(CON, O_WRONLY);
should do but there are also ways to 'save' the original stdout and
restore it later.  Get him to contact me for details.

On 9/16/06, Johnson Lam [EMAIL PROTECTED] wrote:
 Hi,

 Please help Marton (marton=at=argentina.com), he stuck with a C
 program calling COMMAND.COM:

 
 Now that I moved onto my next step on my project, another issue
 arised...
 If I run this:

 TestDir.bat:
 dir /b c:\testdir d:\dirout.put

 The file dirout.put has the directory output...

 BUT, if I do it this way:

 TestDir2.bat:
 command /c dir /b c:\testdir d:\dirout.put

 The file dirout.put has the directory output but CUT... it never
 reaches the end of the output, it just cuts...

 Tried with many command coms and kernel versions...

 I really need to do it that way because I'm using the system()
 function on my C program and it runs command /c with what to run as
 an argument.

 Any ideas on that?

 Kind regards,
 Marton
 

 -
 Using Tomcat but need to do more? Need to support web services, security?
 Get stuff done quickly with pre-integrated technology to make your job
 easier
 Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
 http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
 ___
 Freedos-user mailing list
 Freedos-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/freedos-user



-- 
Fall is my favorite season in Los Angeles, watching the birds change
color and fall from the trees.
   David Letterman (1947 - )

See ya

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user


Re: [Freedos-user] Need help ... calling COMMAND.COM from C

2006-09-16 Thread Johnson Lam
On Sat, 16 Sep 2006 02:29:02 -0700, you wrote:

Hi Blair,

Thanks. Sent him email.

Hi.  It almost sounds to me like the destination file isn't getting
flushed to the disk.  I would recommend doing the recirection
internally in the C program, and then you have direct control of the
file.  A simple close(1); open(blah, O_WRONLY); /* system() stuff
here: */ blah blah blah close(1); open(CON, O_WRONLY);
should do but there are also ways to 'save' the original stdout and
restore it later.  Get him to contact me for details.

Rgds,
Johnson.

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user


Re: [Freedos-user] Need help ... calling COMMAND.COM from C

2006-09-16 Thread Arkady V.Belousov
Hi!

16-Сен-2006 02:29 [EMAIL PROTECTED] (Blair Campbell) wrote to
freedos-user@lists.sourceforge.net:

BC Hi.  It almost sounds to me like the destination file isn't getting
BC flushed to the disk.  I would recommend doing the recirection
BC internally in the C program, and then you have direct control of the
BC file.  A simple close(1); open(blah, O_WRONLY); /* system() stuff
BC here: */ blah blah blah close(1); open(CON, O_WRONLY);
BC should do but there are also ways to 'save' the original stdout and
BC restore it later.  Get him to contact me for details.
 BUT, if I do it this way:
 command /c dir /b c:\testdir d:\dirout.put
 The file dirout.put has the directory output but CUT... it never
 reaches the end of the output, it just cuts...

 This is bug in FreeCOM. And this is reason, why in my patches for
FreeCOM I was tried to move command.com placement into bin/ subdirectory,
else (buggy) command.com (may) interfere with building process, but by some
unknown reason you reject this part of patches.

 About manual redirecting: using open(CON) is wrong, because this
prevents using program with redirection. The more so, if program uses
stdio..h, this way is even more wrong. I think, better way is something
like:

int redirfd = open (d:\dirout.put, O_CREAT | O_TRUNC | O_RDWR,
 S_IREAD | S_IWRITE);
if (redirfd != -1) { /* check for error */
  /* if using standard streams from stdio.h: */
  flushall (); /* flush all high level buffers */
  /* now privately store own stdout... */
  int oldstdout = dup (1);
  /* ...and open redirection */
  dup2 (redirfd, 1); close (redirfd);

  ...now do system(), spwan*() or exec*()...

  dup2 (oldstdout, 1); close (oldstdout);
}

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user


Re: [Freedos-user] Need help ... calling COMMAND.COM from C

2006-09-16 Thread Blair Campbell
I did say that there were ways to save/restore the original stdout...
I know that open(CON) is technically wrong, but at the same time it
works in most cases.

On 9/16/06, Arkady V.Belousov [EMAIL PROTECTED] wrote:
 Hi!

 16-Сен-2006 02:29 [EMAIL PROTECTED] (Blair Campbell) wrote to
 freedos-user@lists.sourceforge.net:

 BC Hi.  It almost sounds to me like the destination file isn't getting
 BC flushed to the disk.  I would recommend doing the recirection
 BC internally in the C program, and then you have direct control of the
 BC file.  A simple close(1); open(blah, O_WRONLY); /* system() stuff
 BC here: */ blah blah blah close(1); open(CON, O_WRONLY);
 BC should do but there are also ways to 'save' the original stdout and
 BC restore it later.  Get him to contact me for details.
  BUT, if I do it this way:
  command /c dir /b c:\testdir d:\dirout.put
  The file dirout.put has the directory output but CUT... it never
  reaches the end of the output, it just cuts...

  This is bug in FreeCOM. And this is reason, why in my patches for
 FreeCOM I was tried to move command.com placement into bin/ subdirectory,
 else (buggy) command.com (may) interfere with building process, but by some
 unknown reason you reject this part of patches.

  About manual redirecting: using open(CON) is wrong, because this
 prevents using program with redirection. The more so, if program uses
 stdio..h, this way is even more wrong. I think, better way is something
 like:

 int redirfd = open (d:\dirout.put, O_CREAT | O_TRUNC | O_RDWR,
  S_IREAD | S_IWRITE);
 if (redirfd != -1) { /* check for error */
   /* if using standard streams from stdio.h: */
   flushall (); /* flush all high level buffers */
   /* now privately store own stdout... */
   int oldstdout = dup (1);
   /* ...and open redirection */
   dup2 (redirfd, 1); close (redirfd);

   ...now do system(), spwan*() or exec*()...

   dup2 (oldstdout, 1); close (oldstdout);
 }

 -
 Using Tomcat but need to do more? Need to support web services, security?
 Get stuff done quickly with pre-integrated technology to make your job
 easier
 Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
 http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
 ___
 Freedos-user mailing list
 Freedos-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/freedos-user



-- 
Fall is my favorite season in Los Angeles, watching the birds change
color and fall from the trees.
   David Letterman (1947 - )

See ya
-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user


Re: [Freedos-user] Need help ... calling COMMAND.COM from C

2006-09-16 Thread Arkady V.Belousov
Hi!

16-Сен-2006 09:12 [EMAIL PROTECTED] (Blair Campbell) wrote to
freedos-user@lists.sourceforge.net:

BC I did say that there were ways to save/restore the original stdout...

 But you not explain this for man, to whom you answer.

BC I know that open(CON) is technically wrong, but at the same time it
BC works in most cases.

 But why at once not write code, which (should) work in _all_ (not
most) cases? Especially, this is not complex.

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user