The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > Windows & DOS: Issues & Discussions
.
google unix.com



Windows & DOS: Issues & Discussions All Windows and DOS questions should go here as well. Discuss UNIX to Windows (Desktop or Server) here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
simple CSH Script behaves differently on Solaris and RedHat Linux two reelers Shell Programming and Scripting 2 02-02-2009 08:39 AM
Script behaves different when run from cron vs. manually billtwild Shell Programming and Scripting 2 11-21-2008 05:54 PM
Script behaving differently on two servers mhssatya UNIX for Advanced & Expert Users 5 09-13-2006 02:28 PM
Script behaving differently in Crontab.. newtoxinu Shell Programming and Scripting 4 10-01-2004 01:22 PM
Script behaving differently in Crontab.. newtoxinu UNIX for Advanced & Expert Users 1 09-30-2004 04:00 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-31-2009
vidyak vidyak is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 9
Awk script in DOS and Linux behaves differently :(

Hi,

I have an awk script which performs simple operations of variable assignments and finally printing the variables in custom form.

Code:
BEGIN {FS=OFS="\n"}
{
   v1=substr($0,1,15)
   v2=substr($0,16,200)
   v3=substr($0,216,20)
   print v1 "|" v2 "|" v3
}
The input file being processed is a fixed width file of record length=4346. The above script works perfectly as expected on Windows (using Windows Unix utilities). When I try to run the same script "as is" on Linux, I get the following error -
a.awk:7: ^ invalid char '' in expression"

I tried to debug the above script line by line and I find that the second line (assigning value to v2) is causing issues on Linux. Wondering, if are there any limitations of using substr to read $0 repeatedly has issues on Linux?

Kindly help.

Thanks and Regards,
Vidya

Last edited by Yogesh Sawant; 04-01-2009 at 01:47 PM.. Reason: added code tags
  #2 (permalink)  
Old 03-31-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361

That script runs without any problem on my Linux box.

My first thought was that perhaps you had carriage returns in the file, but that doesn't seem to affect the script. However, try removing any carriage returns as a first step; it can't hurt.

After that, check to see whether there are any other non-ASCII characters in the file.
  #3 (permalink)  
Old 04-01-2009
vidyak vidyak is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 9
Thanks a lot. Instead of using Editplus to edit the file remotely, when I edited the file directly on Linux, it worked fine for me too. I guess, Editplus inserted some sort of carriage return when saved on Windows which would have caused the problem.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0