LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-16-2006, 06:33 PM   #1
hbinded
Member
 
Registered: May 2006
Distribution: Slackware & MyLFScratch
Posts: 37

Rep: Reputation: 15
[Question] Cat command with sudo


Hi, I have one question; how can I intergrate the "cat" command with sudo? for example:
Code:
sudo cat >> /usr/share/sgml/docbook/sgml-dtd-3.1/catalog << "EOF"
  -- Begin Single Major Version catalog changes --

PUBLIC "-//Davenport//DTD DocBook V3.0//EN" "docbook.dtd"

  -- End Single Major Version catalog changes --
EOF
This always outputs an error. I've tried putting quotes but no success. Is it really possible?

Thanks in advance
 
Old 12-16-2006, 06:47 PM   #2
hbinded
Member
 
Registered: May 2006
Distribution: Slackware & MyLFScratch
Posts: 37

Original Poster
Rep: Reputation: 15
oops, sorry, posted in the wrong forum. If possible, please move. Thanks
 
Old 12-16-2006, 10:21 PM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Note I have to escape " in the string...

Code:
sudo bash -c "cat >> /usr/share/sgml/docbook/sgml-dtd-3.1/catalog <<EOF
  -- Begin Single Major Version catalog changes --

PUBLIC \"-//Davenport//DTD DocBook V3.0//EN\" \"docbook.dtd\"

  -- End Single Major Version catalog changes --
EOF"
 
Old 12-17-2006, 10:51 PM   #4
hbinded
Member
 
Registered: May 2006
Distribution: Slackware & MyLFScratch
Posts: 37

Original Poster
Rep: Reputation: 15
Thanks a million. You've really helped me! ;-)
 
Old 12-18-2006, 01:53 AM   #5
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
No worries. I've come across this myself when sudoing stuff in Ubuntu, but it didn't occur to me how to solve it in one command until I saw your post Inspiration is a funny thing.
 
  


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
Restricting Editing in Sudo (Advanced Sudo Question) LinuxGeek Linux - Software 4 11-04-2006 03:20 PM
Cat and Sed Command Help. vidyashankara Linux - General 22 06-23-2006 01:32 PM
cat command juanb Linux - Newbie 4 08-19-2004 11:14 AM
what are the limits to the 'cat' command? Frybyte Linux - General 12 04-22-2004 04:32 PM
cat Command Moeses Linux - General 1 06-20-2002 03:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:32 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