This is a discussion on print data to txt within the Shell scripting forums, part of the Development/Scripting category; I am currently working on a PL file. where i encounter some errors. I am trying to create a dir ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
I am currently working on a PL file. where i encounter some errors.
I am trying to create a dir if it is not available : ######################## 23 FILEPATH = '/trs/wg/'.$ToDate.'/' 24 print "Filepath is $FILEPATH\n"; 25 if [ ! -d $FILEPATH ] 26 then 27 mkdir $FILEPATH 28 fi ######################## The error was : Semicolon seems to be missing at printfile.pl line 25. Semicolon seems to be missing at printfile.pl line 27. printfile.pl had compilation errors. Anyone can help me? |
| Sponsored Links | ||
|
|
|
|||
|
If by PL you mean Perl, then your IF/THEN logic needs to use Perl syntax, not Bash syntax:
23 FILEPATH = '/trs/wg/'.$ToDate.'/'; 24 print "Filepath is $FILEPATH\n"; 25 if ( ! -d $FILEPATH ){ 27 mkdir $FILEPATH; 28 } ...Use parentheses () instead of brackets [] to enclose your condition-test statement. Use curly-braces {} to enclose your conditionally-executed block of logic, instead of the 'then' and 'fi' keywords. It is safer to conclude every statement in Perl with a semicolon, like in C, than to see which ones you can get away without (the last one in a curly-brace-enclosed block ...but does it stay the last one when you're busy editing and debugging?). There is a curly-free way to express a simple conditional statement by flipping the order of the test and dependent-logic: mkdir $FILEPATH unless -d $FILEPATH; ...and I use those only for simple lines I can read at a glance. (Notice that I used the 'unless' keyword, which is logically "if !" but more readable.) fwiw cr |
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to print some lines from a file | Prahlad | Shell scripting | 3 | 04-24-2008 12:25 AM |
| How to make leafpad to print | satimis | Linux software | 0 | 12-25-2007 08:36 PM |
| Ubuntu 7.04 doesn´t print with HP K550 printer latest firmware | joaquinnegrete | Linux hardware | 0 | 06-13-2007 06:31 PM |
| Load balancing pooling print jobs using CUPS print queues | raj | Getting started tutorials | 0 | 01-16-2007 10:08 PM |
| Ubuntu Linux: How do I setup print quotas? | cityblogger | Linux software | 1 | 07-06-2006 06:11 PM |