CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
sed in perl

 



ab52
New User

Feb 21, 2014, 6:11 AM

Post #1 of 3 (654 views)
sed in perl Can't Post

Hi all

I have this sed command that works find on the command line but when i call it from a perl script is errors


Code
sed -i '13 i <key>AllowClearTextPasswords</key>\n<true/>' file.txt


i get this error


Code
 
sed: -e expression #1, char 41: unknown command: `<'


Any ideas? i have tired escaping the < but i dont think i had it right


Laurent_R
Veteran / Moderator

Feb 21, 2014, 10:05 AM

Post #2 of 3 (644 views)
Re: [ab52] sed in perl [In reply to] Can't Post

Please show how you call it from Perl. I can't answer without that.

But the main point is that there is no point calling a sed command from Perl, since Perl can do everything that sed can do, and it can do it better and il most cases faster. You should do it in Perl.


ab52
New User

Feb 24, 2014, 12:46 AM

Post #3 of 3 (629 views)
Re: [Laurent_R] sed in perl [In reply to] Can't Post

this is my code


Code
my $searchterm=`defaults read /Users/$USER/Library/Preferences/com.apple.iChat.Jabber.plist | grep -w "AllowClearTextPasswords = 1"`; 
if ( $? !=0 ) {
_log("Converting com.apple.iChat.Jabber.plist to xml ");
system("plutil -convert xml1 /Users/$USER/Library/Preferences/com.apple.iChat.Jabber.plist");
_log("Adding in the correct line");
my $cmd = "/apps/MacOS/ports/10.8/libexec/gnubin/sed -i '13 i <key>AllowClearTextPasswords</key>\n<true/>' /Users/$USER/Library/Preferences/com.apple.iChat.Jabber.plist";
system("$cmd");
}


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives