Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   Dev Hardware ForumsSOFTWAREProgramming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Hardware Forums Sponsor:
  Trader Rating: 0 · #1  
Old March 5th, 2008, 12:55 PM
flamey flamey is offline
n00b DevH'er
Dev Hardware Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 10 flamey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 12 m 40 sec
Reputation Power: 0
NT Batch - Help me understand this batch feature

While looking for ways to automate some things in ClearCase (ibm's source control), i found following file, and it works fine in regular command prompt (WinXP). but I don't understand HOW!

I know what perl code there does, i understand why it jumps over it with goto. what I don't understand how does "ccperl" command knows to take input from that section!

Code:
@echo off
ccperl %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofperl
@rem ';

my @priv = `cleartool lsprivate -tag $ARGV[0]`;
foreach $priv (@priv) 
{
    print $priv;
}

__END__
:endofperl

Reply With Quote
  Trader Rating: 1 · #2  
Old March 5th, 2008, 01:22 PM
weevilofdoom's Avatar
weevilofdoom weevilofdoom is offline
BLURG
Dev Hardware Loyal (3000 - 3499 posts)
 
Join Date: Sep 2004
Location: Oregon
Posts: 3,420 weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)  Folding Points: 32443 Folding Title: Starter FolderFolding Points: 32443 Folding Title: Starter Folder
Time spent in forums: 2 Months 1 Day 23 m 12 sec
Reputation Power: 3411
Send a message via ICQ to weevilofdoom Send a message via AIM to weevilofdoom Send a message via MSN to weevilofdoom Send a message via Yahoo to weevilofdoom Send a message via Google Talk to weevilofdoom
%0 %1 etc are command line arguments. %0 is always the path to the executable being executed... so that's what is being passed to ccperl ... as for how it gets to the loop in the middle, i'll never know ... it looks as if it skips it completely every time.
__________________

Reply With Quote
  Trader Rating: 0 · #3  
Old March 5th, 2008, 01:56 PM
flamey flamey is offline
n00b DevH'er
Dev Hardware Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 10 flamey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 12 m 40 sec
Reputation Power: 0
ah! ok, that kinda makes sense. thank you!

so basically it will execute "ccperl mybatch.bat", and I'm guessing this clearcase version of perl knows how to ignore the batch commands and interpret only the perl code. i'll look for ccperl docs..

Thanks!

Reply With Quote
  Trader Rating: 0 · #4  
Old March 5th, 2008, 01:56 PM
DrStrangluv's Avatar
DrStrangluv DrStrangluv is offline
Contributing User
Dev Hardware Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 183 DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 5 Days 11 h 10 m 6 sec
Reputation Power: 320
Googling some other ccperl scripts, it looks like ccperl is designed to ignore everything between @echo off and @rem ';. The odd syntax for accomplishing this makes me think it's just a well-known side effect of some other feature that experienced ccperl users often take advantage of. So when the file is passed to ccperl, all it sees it the real perl code.

I guess the only real advantage to doing it this way is you so can double click on the script or just drag and drop a file on it in explorer, rather than having to invoke ccperl directly on the command line.

Reply With Quote
  Trader Rating: 0 · #5  
Old March 5th, 2008, 02:03 PM
DrStrangluv's Avatar
DrStrangluv DrStrangluv is offline
Contributing User
Dev Hardware Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 183 DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level)DrStrangluv User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 5 Days 11 h 10 m 6 sec
Reputation Power: 320
Okay, I understand it a little better now. The @echo off line plays double duty. In addition to it's normal dos batch behavior, the initial @ sign means when perl starts it things you're declaring an array variable named echo. So that line is valid batch and valid perl at the same time. With no line terminator (; character), everything up to @rem '; is part of that declaration. You need @rem on the end so batch interprets the line as a comment and doesn't complain.

-- sort of. The other examples I saw all used something like this on the first line:
@rem= 'PERL for Windows NT - ccperl must be in search path

That makes a lot more sense, because you're actually initializing a string variable, and batch will still ignore it. I don't know how the perl interpreter handles things with just the @echo off, since you never told it you were starting a string. Are you maybe missing a line?

Reply With Quote
  Trader Rating: 0 · #6  
Old March 5th, 2008, 02:32 PM
flamey flamey is offline
n00b DevH'er
Dev Hardware Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 10 flamey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 12 m 40 sec
Reputation Power: 0
yes, you're absolutelly right! i took it out before posting here trying to keep it simple w/o realizing its purpose. thank you!

and the purpose would be keeping it all in one file.

Reply With Quote
Reply

Viewing: Dev Hardware ForumsSOFTWAREProgramming > NT Batch - Help me understand this batch feature


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway