473,386 Members | 1,830 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,386 software developers and data experts.

C - on Windows Odd behavior

140 100+
Hi,

I'm getting a weird error with my C program. It receives parameters from a text file that is created by a VB wrapper program. One of the inputs is a "jobname". The code bombs when certain values are inputed for this jobname, but not others. This jobname is used to create a directory.

It crashes when the jobname has LLLLLLL_###LL, where L = letters, and # = digits, and _ = underscore. But, if there are only 2 digits & 2 letters or 1 letter after the 3 digits it works fine. Unfortunately, the user typically names the job name with this format (ex: "Bottle_400ml").

Has anyone seen anything like this before?

Thanks,
Sitko.
Dec 5 '07 #1
10 1721
weaknessforcats
9,208 Expert Mod 8TB
Post the code that reads the jobname.

"weird error" is a little vague. Exactly what kind of error??
Dec 5 '07 #2
sitko
140 100+
The error that pops up is:
"D:\Bottle_400mL
'-^' is not recognized as an internal or external command,
operable program or batch file.
The filename, directory name or volume label syntax is incorrect."
(note: the "^" symbol is an "up arrow" character.)

At first instead of "-^" it said "/Decline" is not recognized as an internal...

The code that I 'think' cause the error was this:
Expand|Select|Wrap|Line Numbers
  1. if (strcmp(strType,"Decline")==0)  
  2.         {                                
  3.             strcpy(sysCall,"mkdir ");
  4.             strcat(sysCall,gstrJobname);
  5.             system(sysCall);
  6.         }
  7.         if (strcmp(strType,"Decline")==0)
  8.         {
  9.             strcpy(sysCall, "mkdir ");
  10.             strcat(sysCall, gstrJobname);
  11.             strcat(sysCall, slash);
  12.             strcat(sysCall, strType);
  13.             system(sysCall);
  14.         }
  15.  
I use conditional compilation statements, so that this code runs on both windows and unix.
'Slash" = whichever slash type is appropriate for whichever platform we're compiled on.
gstrJobname = the jobname the user typed in.
strType is either "Shake" or "Decline".

Thanks,
Sitko.
Dec 5 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
if (strcmp(strType,"Decline")==0)
{
strcpy(sysCall,"mkdir ");
strcat(sysCall,gstrJobname);
system(sysCall);
}
if (strcmp(strType,"Decline")==0)
{
strcpy(sysCall, "mkdir ");
strcat(sysCall, gstrJobname);
strcat(sysCall, slash);
strcat(sysCall, strType);
system(sysCall);
}
Tell me again how this code works. It looks like the strcmp is true in each case-and yioiu haver different contents.

Also, on the Windows side, your slash has to be \\.
Dec 5 '07 #4
sitko
140 100+
I do have \\ on the windows side. LIke I said, this code works fine, EXCEPT for when the user inputs a job name with "_###LL" in it.

The code itself creates some text files, and a directory structure, which are fed into a downstream process. I can't go into too much detail as I've signed a NDA.

I don't think a code snipet is really helpful in this case, as it works fine, if they don't input that certain string value. So, it seems that C doesn't like that substring value for some reason.

Thanks,
Sitko.
Dec 5 '07 #5
weaknessforcats
9,208 Expert Mod 8TB
Well, I was just wondering where the strTtype of "Shake" was. It's not in tyour code snippet.

There's nothing in C that prevents a jobname with # in it as you describe.
Dec 5 '07 #6
sitko
140 100+
thanks...I didn't think it would...just wanted the opinion from you "experts"...what about if the string was ###_mL? Could the act of hitting "shift" to get the uppercase L case a problem?
Dec 5 '07 #7
weaknessforcats
9,208 Expert Mod 8TB
"experts"...
You have to remember that X is an unknown qunatity and that a spurt is just a drip under pressure.

The shift key is not an issue. That just determines the value you receive fromthe keyboard.

Your problem is elsewhere. You might look at the VBA.
Dec 6 '07 #8
sitko
140 100+
You have to remember that X is an unknown qunatity and that a spurt is just a drip under pressure.

The shift key is not an issue. That just determines the value you receive fromthe keyboard.

Your problem is elsewhere. You might look at the VBA.
Its definitely, in the C code where the error is happening. The VB front end, just builds the input.txt file for the C code, and I've checked and double checked, and everything is right going into the C code. Since then, I've seen a new "error" string with this code, another guy got "--<down arrow>" as being the offensive line.
Dec 10 '07 #9
weaknessforcats
9,208 Expert Mod 8TB
At some point you wuill have to post the code that's failing.
Dec 10 '07 #10
sitko
140 100+
Yeah, unfortunately, TPTB (the powers that be) have decided for the short term to just not use input that causes the problem, instead of investing time narrowing down the location of the offensive code. As the original error we got was "/Decline" is not a command, etc. I thought I had included the offending code in post #3 above.

The gstrJobName is read in like all the rest of the parameters, its code is this:

Its definition is:
Expand|Select|Wrap|Line Numbers
  1. char gstrJobDir[200];
  2.  
My input file is based on one input parameter per line in a specified order. The VB file creates this input when the user clicks the 'write' button. The VB creates the file saves it in the folder and then calls the C program.
I have an "Assign Variables' function which loads all the global variables with values from the input file.

Expand|Select|Wrap|Line Numbers
  1. if( (filePtr = fopen("Input.txt","r") )== NULL)
  2.     {
  3.         printf("ERROR: The input file can not be opened.");
  4.         exit(1);
  5.     }
  6.  
  7.     fscanf(filePtr, "%s", Jobname);
  8.     fscanf(filePtr, "%s", Bottlename);
  9.  
Here is where I move the Jobname into the gstrJobName:
Expand|Select|Wrap|Line Numbers
  1.         strncpy(tempStr2,Jobname,(strlen(Jobname)));
  2.     strcpy(gstrJobname,tempStr2);
  3.  
Here is my code to build the job directory, along with some of my conditional compilation code:
Expand|Select|Wrap|Line Numbers
  1.     //find the directory from the strBottleFile, 
  2.         //which is everything before the last slash.
  3. #if _WIN32
  4.     {pch=strrchr(gstrBottleFile,'\\');}
  5. #else
  6.     { pch=strrchr(gstrBottleFile,'/');}
  7. #endif
  8.     intLastSlash = (pch-gstrBottleFile+1);
  9.     strncpy (gstrWorkingDir,gstrBottleFile,intLastSlash);
  10.  
  11.     //build the jobdir from working directory & "/" & jobname
  12.     strcpy(gstrJobDir,gstrWorkingDir);
  13.     strcat(gstrJobDir,gstrJobname);
  14.  
I can't really post more of the code, than this. I know that makes it hard, but these snipets contain all of the code that references that global variable gstrJobName...

I hope that helps...
Dec 10 '07 #11

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

Similar topics

6
by: Bharath Dhurjati | last post by:
Hello, I am looking for documentation that specifies the following behavior exhibited by java. The following (assuming MyClass.class is accessible and has a main()) java MyClass * yields...
15
by: Georgy Pruss | last post by:
On Windows XP glob.glob doesn't work properly for files without extensions. E.g. C:\Temp contains 4 files: 2 with extensions, 2 without. C:\Temp>dir /b * aaaaa.aaa bbbbb.bbb ccccc ddddd ...
2
by: MatthewRoberts | last post by:
Howdy All, I have a Windows Service that often stops in its tracks with no exception and no explanation on our QA system. During testing on the development machine, it can handle any workload,...
0
by: Leo | last post by:
Does someone know if there is a setting in the python Unix world to make the command history behave as it does in the Windows intepreter? Specifically, I like the fact that the command history...
2
by: David | last post by:
Hello, I have an application that has been running for years and had little problem with it. We've been retesting the latest code under Windows 2003 and found a surprise. There is a certain...
5
by: R. Ian Lee | last post by:
I'm using the System.Web.Mail.SmtpMail object (.NET 1.1) to send email from an ASP.NET application. Everything works fine when I run it from Windows 2000 Server, but not from WinXP Pro. Is it...
23
by: Dan Tallent | last post by:
A textbox has a attribute for ReadOnly. This seems like such a simple concept. When a textbox is set to read only the user cannot change the contents of the field. I have been trying to find...
23
by: asit | last post by:
what is the difference between portable C, posix C and windows C ???
3
by: shobhitguptait | last post by:
How to Run C#.NET Windows App on N/W with centralized DB using SQL SERVER 2000 Hello All...i m really grate full to c such a website where developers try to help people like us who face problems...
0
by: khurramlone | last post by:
I am trying to generate a client proxy from a WCF service library. I am using VS2005, .NET 3.0 on a Windows XP Pro workstation. The WCF service is hosted in a windows service. When I run the windows...
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: 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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.