LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-24-2015, 07:11 PM   #1
gjwalsh
Member
 
Registered: Oct 2010
Location: Victoria, B.C., Canada
Distribution: OpenSuSE Tumbleweed
Posts: 30

Rep: Reputation: 0
enscript works from command line as an alias when -G is used, but fails otherwise


Test case 1:
An alias reading 'enscript -G -f "Courier9" ' <filepathname>
works as expected but with that heavy header I do not want.
The $D (date) and $N (full file name) values are implicitly picked up from the
target <filepathname> .

Test Case 2:
To produce an alternative I developed the following command line:

enscript --margins=64:64:40:40 -f Courier9 -F AvantGarde-DemiOblique10 --header='$D|$N|Page $ of $= ' <filepathname>

This works perfectly.

Test Case 3:
And so, exhilarated by this success, I built an alias to do the job and placed it in the user's .bashrc file.

alias enlistc="enscript --margins=64:64:40:40 -f Courier9 -F AvantGarde-DemiOblique10 --header='$D|$N|Page $% of $=' " <filepathname>

The result was a page with the margins I required, the correct font and size in the body of the output, but the header was another matter. The paging was correct and in the correct font and size as well, but $D and $N are absent.

What is the best way out of this? I am surprised because invoking -G brings in values for $D and $N without any explicit instruction (Case 1) whereas in (Case3)
the explicit $D and $N are ignored within the --header definition.

A leg up would certainly be appreciated ....

Last edited by gjwalsh; 10-24-2015 at 11:25 PM. Reason: --header= ' <replacing> --header '
 
Old 10-25-2015, 11:54 AM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
The expansion of $D and $N is occurring at the time you set the alias. At the time you issue the alias command, the single quotes around the header expression have no special meaning (they are within a double quoted string) and so do not protect the "$" characters.

This should work:
Code:
alias enlistc="enscript --margins=64:64:40:40 -f Courier9 -F AvantGarde-DemiOblique10 --header='\$D|\$N|Page $% of $=' "
 
1 members found this post helpful.
Old 10-25-2015, 06:57 PM   #3
gjwalsh
Member
 
Registered: Oct 2010
Location: Victoria, B.C., Canada
Distribution: OpenSuSE Tumbleweed
Posts: 30

Original Poster
Rep: Reputation: 0
Ugh! I was trying everything except the old reliable escape '\'.
Thanks so much for taking the trouble to respond. It's always the simple things which seem to evade me!
With my regards,
"George"
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
script fails but works fine when entered line-by-line in terminal misterjones Linux - General 3 11-14-2013 10:30 PM
bash: command works at command line, but not via an alias porphyry5 Programming 3 03-17-2012 02:48 PM
crontab fails but command line works - sir-lancealot Linux - Server 3 02-19-2011 04:43 PM
[SOLVED] Keyboard problems: virt-manager fails, but kvm from the command line works kenneho Linux - Virtualization and Cloud 1 11-14-2009 11:11 AM
Bash script works from command line, fails from cron cmfarley19 Linux - General 4 08-14-2009 12:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration