PDA

View Full Version : change forefox proxy using command line



vksingh
September 19th, 2010, 05:38 AM
Hi,


How to change firefox proxy using command line in ubuntu.

Thanks,

Vivek

kurum!
September 19th, 2010, 03:07 PM
#!/usr/bin/env ruby -w
home=File.expand_path("~")
found=""
Dir.glob("#{home}/**/prefs.js", File::FNM_DOTMATCH).each do |file|
found<<file if file =~ /firefox.*default\/prefs.js$/
end
newproxy = '"new.proxy.com");'
newfile = File.open("temp", "w")
File.open(found).each do |line|
if line =~ /network.proxy.http/
x,y = line.chomp.split(", ")
line=[x,newproxy].join(", ")
end
newfile.print line
end
newfile.close
File.rename(found, "old.orig")
File.rename("temp", found)

vksingh
September 20th, 2010, 06:45 AM
#!/usr/bin/env ruby -w
home=File.expand_path("~")
found=""
Dir.glob("#{home}/**/prefs.js", File::FNM_DOTMATCH).each do |file|
found<<file if file =~ /firefox.*default\/prefs.js$/
end
newproxy = '"new.proxy.com");'
newfile = File.open("temp", "w")
File.open(found).each do |line|
if line =~ /network.proxy.http/
x,y = line.chomp.split(", ")
line=[x,newproxy].join(", ")
end
newfile.print line
end
newfile.close
File.rename(found, "old.orig")
File.rename("temp", found)




Hi,

Thanks for your help.
I tried to run your script but, I am getting following error:

/usr/bin/env: ruby -w: No such file or directory


Please help.

Thanks,

Vivek

kurum!
September 20th, 2010, 07:24 AM
you have to install ruby if you want to use the script. otherwise, wait for someone else for alternative