- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Trying to convert all .ps files in one directory t...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2009 12:07 PM
тАО09-30-2009 12:07 PM
Trying to convert all .ps files in one directory to .pdf
I am trying to get ps2pdf to work within a script so that it will convert all .ps files that are in a directory, to .pdf format.
What would the command syntax be in order for me to accomplish this? Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2009 12:19 PM
тАО09-30-2009 12:19 PM
Re: Trying to convert all .ps files in one directory to .pdf
Add ps2pdf options according to your taste.
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2009 12:24 PM
тАО09-30-2009 12:24 PM
Re: Trying to convert all .ps files in one directory to .pdf
Thanks for your reply. I inserted the command syntax in question, but the output I got was the following:
Usage: ps2pdfwr [options...] (input.[e]ps|-) [output.pdf|-]
Usage: ps2pdfwr [options...] (input.[e]ps|-) [output.pdf|-]
Usage: ps2pdfwr [options...] (input.[e]ps|-) [output.pdf|-]
Usage: ps2pdfwr [options...] (input.[e]ps|-) [output.pdf|-]
Usage: ps2pdfwr [options...] (input.[e]ps|-) [output.pdf|-]
Usage: ps2pdfwr [options...] (input.[e]ps|-) [output.pdf|-]
Usage: ps2pdfwr [options...] (input.[e]ps|-) [output.pdf|-]
What am I missing here? Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2009 12:32 PM
тАО09-30-2009 12:32 PM
Re: Trying to convert all .ps files in one directory to .pdf
To start...
1. A description of a ps2pdf command which
works as you'd like on one file.
2. A useful description of the actual
command(s) which failed.
> [...] I inserted the command syntax in
> question [...]
Not a useful description of your starting
point, or of what produced the undesired
output. That new-fangled copy+paste
technology makes it pretty easy to show your
actual commands with their actual output,
all of which is generally superior to vague
descriptions and interpretations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2009 12:41 PM
тАО09-30-2009 12:41 PM
Re: Trying to convert all .ps files in one directory to .pdf
Sorry about the vagueness in my postings. When I run the ps2pdf command manually on one file, the syntax is similar to the following:
/usr/bin/ps2pdf 'Course 1.Plan 1.ISOCENTER_SUMMARY.ps'
The pdf file is successfully created.
The command syntax that I used in the script which failed are as follows:
for i in *.ps;
do ps2pdf $i;
done
Seriously, does that clarify things?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2009 02:13 PM
тАО09-30-2009 02:13 PM
Re: Trying to convert all .ps files in one directory to .pdf
Some. Perhaps enough.
What are the file names? "ls -l"?
> /usr/bin/ps2pdf 'Course 1.Plan 1.ISOCENTER_SUMMARY.ps'
> do ps2pdf $i;
Not really the same, are they? One has a
full path to "ps2pdf". One has a quoted
argument. (Why? Funny file names which need
quotation?)
A little debug output might be informative.
For example:
do echo ">${i}<" ; ps2pdf $i
Personally, I tend to avoid things like
"*.ps" in a shell script. I assume that the
shell will get a too-long line, or some file
name with embedded spaces will get broken
apart, or some other disaster will befall it.
"find" is harder to use, but also harder to
bewilder.
Oh, look. What's that between "Course" and
"1"? Could it be a space?
Something like
ps2pdf "$i"
might be helpful.
See what I mean about actual stuff instead of
descriptions of stuff?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-03-2009 11:37 AM
тАО10-03-2009 11:37 AM
Re: Trying to convert all .ps files in one directory to .pdf
find . -name "*.ps" | while read file; do
ps2pdf "$file"
done
(This will descend into subdirectories.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-03-2009 02:08 PM
тАО10-03-2009 02:08 PM
Re: Trying to convert all .ps files in one directory to .pdf
> you.
If you're careless.
> I don't think you can use a for-loop
> and you should use find(1):
Actually, "for" seems to be smarter than I'd
expect:
dy # for i in a* ; do echo "$i" ; done
a b c
a b.c d
dy # uname -a
HP-UX dy B.11.11 U 9000/785 2012616114 unlimited-user license
Could depend on your shell, of course.
UNIX(-like) shells don't make it particularly
easy to handle spaced file names, but it can
often be done, if one pays attention to
details.
VMS (on an ODS5 file system) does things
differently, of course:
bash$ ls -l a*b*
-rw-r----- 1 SMS 40 5 Jan 26 2009 a b c d
-rwxr-x--- 1 SMS 40 8 Apr 18 2008 a.b.c.d
-rwxr-x--- 1 SMS 40 3654 May 17 2006 a.b.c.d.e
-rw-r----- 1 SMS 40 0 Jul 28 01:02 a:b
alp $ dire /date /prot /size a*b*
Directory DKA100:[sms]
a^_b^_c^_d.;1 1 26-JAN-2009 15:39:50.55 (RWD,RWD,R,)
a^.b^.c.d;1 1 18-APR-2008 22:04:10.44 (RWED,RWED,RE,)
a^.b^.c^.d.e;1 8 17-MAY-2006 15:20:43.38 (RWED,RWED,RE,)
a^:b.;1 0 28-JUL-2009 01:02:35.88 (RWD,RWD,R,)
Total of 4 files, 10 blocks.
You can use literal spaces with the C RTL,
and you can actually use "^ " on the command
line, but that caret-escape mechanism, deftly
(?) avoids literal spaces on the command
line.
bash$ ls -l a\ b*
-rw-r----- 1 SMS 40 5 Jan 26 2009 a b c d
alp $ dire /date /prot /size a^ b*
Directory DKA100:[sms]
a^_b^_c^_d.;1 1 26-JAN-2009 15:39:50.55 (RWD,RWD,R,)
Total of 1 file, 1 block.
You can avoid escaping all the non-last dots,
and some other things, too:
alp $ dire /date /prot /size a.b.c.d.e
Directory DKA100:[sms]
a^.b^.c^.d.e;1 8 17-MAY-2006 15:20:43.38 (RWED,RWED,RE,)
Total of 1 file, 8 blocks.
But there are some details there, also.
Everything's complicated.