whitespace within a string

From: Bart Nessux (bart_nessux_at_hotmail.com)
Date: 02/24/04


Date: Mon, 23 Feb 2004 20:22:25 -0500

Is there a function/module that can be used to throw out extra whitespace
that appears within a string? The problem that I have is this: Before any
configuration is done to my files, they have lines with tabs in between the
words like this:

"disable = yes"

After configuring the files using the operating system's administration
tools, the OS rewrites the files to contain spaces instead of tabs. So now,
the file looks like this:

"disable = yes"

I would like my script to work in either situation. Right now, it only works
with spaces, not tabs. Below is the script:

def enable_ssh():
   # works on 10.3 systems, not 10.2 systems
   import os
   os.chdir('/etc/xinetd.d')
   find = 'disable = yes'
   replace = 'disable = no'
   x = file('ssh')
   data = x.read()
   x.close()
   search = str.find(data, find)
   if search >= 0:
      data = data.replace(find, replace)
      outputFile = file('ssh', 'w')
      outputFile.write(data)
      outputFile.close()
      print
      print "SSH was disabled... service restarted!!!"
      print
   else:
      print
      print "SSH was enabled... no action taken."
      print
enable_ssh()



Relevant Pages

  • Re: Quarantine rqc parameter details
    ... You can find quarntine configuration details at ... Name of the VPN connectiod. ... <String>: This is the shared secret key that client and server knows about. ... You can call rqc with appropriate parameters using VB script. ...
    (microsoft.public.isa)
  • Re: Quarantine rqc parameter details
    ... You can find quarntine configuration details at ... Name of the VPN connectiod. ... <String>: This is the shared secret key that client and server knows about. ... You can call rqc with appropriate parameters using VB script. ...
    (microsoft.public.win2000.ras_routing)
  • Re: Quarantine rqc parameter details
    ... You can find quarntine configuration details at ... Name of the VPN connectiod. ... <String>: This is the shared secret key that client and server knows about. ... You can call rqc with appropriate parameters using VB script. ...
    (microsoft.public.isa.vpn)
  • Re: tab escape not shown in textarea
    ... My string contains "\t" for tabs. ... the escape. ... document.myForm.myTextArea.value ="This is a\t test of this script"; ...
    (comp.lang.javascript)
  • Re: OT: Umra posting statistics for May 2008
    ... rather than adding tabs (which can go all over the place if ... horror when I clicked on the "show formatting" button. ... language Jo's script is written in but something like C or Perl's ... always welcome :-) I'm just using Agent, ...
    (uk.media.radio.archers)