LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 04-09-2008, 09:20 PM   #1
protorox
LQ Newbie
 
Registered: Apr 2008
Posts: 8

Rep: Reputation: 0
Question Please translate this PHP script to BASH


PHP Code:
<?php
$ss 
file('/sbin/ss.list');
$ssNum count($ss);
$thisSSrand rand(1,$ssNum);
$thisSS rtrim($ss[$thisSSrand]);
print 
$thisSS;
?>
 
Old 04-09-2008, 11:04 PM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 238Reputation: 238Reputation: 238
you can use wc to count lines in a file. check man wc
you can use $RANDOM to generate random number. see here too
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Execute bash script inside PHP creatorrr Programming 11 11-21-2007 04:32 PM
run shell script bash from browser with php achilles Programming 10 08-02-2007 03:44 PM
Using PHP, run bash script and see results on Server's Monitor xmrkite Linux - Software 6 10-17-2006 01:28 PM
php and bash script permissions paddyjoy Programming 2 10-04-2006 06:01 PM
Cannot create folders with bash script called from php keyF Linux - Software 4 06-25-2006 10:58 AM


All times are GMT -5. The time now is 12:12 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration