Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
Easy perl question
Results 1 to 5 of 5

Thread: Easy perl question

  1. #1

    Easy perl question

    I have what I would assume to be an easy perl question.

    I am trying to make an input file that contains host names. The names get added to the file by doing something like
    Code:
    cat host.name.edu >>hostnames.txt
    The script then uses the hostnames to connect to the client ussing scp. The problem occurs when we tried it, the perl script keeps reading whitespaces in the line somewhere and ends up creating a bunch of errors. So does anyone know what the code would be to clean up the lines so that only the hostnames are left to pass to the scp command?

  2. #2
    Mentor Stuart's Avatar
    Join Date
    May 2002
    Location
    nb.ca
    Posts
    1,087

    Re:Easy perl question

    Is it reading whitespace or newlines?
    Make sure to chomp() your variables.
    If it is whitespace, a simple substitution (s/ //) should do.

  3. #3

    Re:Easy perl question

    Well that is what we're not sure of... We don't know WHAT its grabbing. this is what we have so far.

    Code:
    open(DAT,"$filein") || die("\nCannot Open File host_list\n");
    @raw = <DAT>;
    @x = &shellwords(@raw);
    $i=0;
    foreach (@x)
    {
    #copy the password files to the computers listed in host_list
    `scp /root/passwd/* root\@$_:/etc/`;
    }
    It does work when we put all the hostnames all on one line separted by a space. but like I said before we want to be able to just append new hosts to the file from the command line.

  4. #4
    Senior Member
    Join Date
    Apr 2002
    Posts
    417

    Re:Easy perl question

    You definitely want to get rid of EOL characters in you data.

    @raw = <DAT>;
    chomp @raw;

  5. #5

    Re:Easy perl question

    Well we ended up changing the loop structure and now it works like a charm... But if someone could tell me why this method works and the other one didn't that would awesome. We did try to put in a chomp in the one above but it didn't work.
    Code:
    open(DAT,"$filein") || die("\nCannot Open File host_list\n");
    #@raw = <DAT>;
    #@x = &shellwords(@raw);
    $i=0;
    foreach $line (<DAT>)
    {
    #copy the password files to the computers listed in host_list
    chomp($line);
    `scp /root/passwd/* root\@$line:/etc/`;
    }

Similar Threads

  1. newbie perl question using Net::OSCAR module
    By countach44 in forum Linux - Software, Applications & Programming
    Replies: 12
    Last Post: 12-10-2003, 04:09 AM
  2. perl question from a perl newb
    By tolstoy in forum Linux - Software, Applications & Programming
    Replies: 4
    Last Post: 09-06-2002, 01:16 AM
  3. PERL DBI Question
    By HuggyBear in forum Linux - Software, Applications & Programming
    Replies: 3
    Last Post: 08-16-2002, 02:45 PM
  4. Whoa, it's easy to trap signals in perl!
    By Feztaa in forum Linux - Software, Applications & Programming
    Replies: 51
    Last Post: 04-24-2002, 04:08 PM
  5. Perl question about user input.
    By Feztaa in forum Linux - Software, Applications & Programming
    Replies: 4
    Last Post: 03-28-2002, 03:44 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •