Jump to content

Search the Community

Showing results for tags 'fgets'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hi, Newbie here, but I'm trying! So, I'm trying to read from a file which contains an IP address then, insert that IP address into my code which, then, opens a telnet session. My code is working but when I read the IP address from the file, the PHP code inserts spaces between the numbers and dots in the IP address, so, instead of reading 192.168.1.1 I'm getting 1 9 2 . 1 6 8 . 1 . 1 which telnet wont recognise. Here is the code:- ?php require_once "php-telnet/PHPTelnet.php"; $telnet = new PHPTelnet(); $file = fopen("switchIPs2.txt", "r") or exit ("File not found!"); { while (!feof($file)) { $ip = fgets($file); $result = $telnet->Connect($ip); } if ($result == 0) { $telnet->DoCommand('password'); $telnet->DoCommand('en'); $telnet->DoCommand('password'); $telnet->DoCommand('copy running-config tftp:'); $telnet->DoCommand('192.168.1.2'); $telnet->DoCommand(''); $telnet->DoCommand('end'); $telnet->DoCommand('exit'); } } fclose($file); ?> Please let me know if you require any further information to help me! Your time is very much appreciated. Kind regards, Jamie.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.