Linux / UNIX Tech Support Forum
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 ...
|
|||||||
| Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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 |
![]() |
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 | 23-04-2008 11:25 PM |
| How to make leafpad to print | satimis | Linux software | 0 | 25-12-2007 07:36 PM |
| Ubuntu 7.04 doesn´t print with HP K550 printer latest firmware | joaquinnegrete | Linux hardware | 0 | 13-06-2007 05:31 PM |
| Load balancing pooling print jobs using CUPS print queues | raj | Getting started tutorials | 0 | 16-01-2007 09:08 PM |
| Ubuntu Linux: How do I setup print quotas? | cityblogger | Linux software | 1 | 06-07-2006 05:11 PM |