Display shell online


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Display shell online
# 1  
Old 10-09-2010
Display shell online

Is there a way to get $random to work in shell? If I don't include bourne shell ( !#/bin/sh ) My program works.... however, I need to include !#/bin/sh in order to display my program on the internet.
# 2  
Old 10-09-2010
#! /bin/sh or !# /bin/sh
# 3  
Old 10-10-2010
Yeah I know that, but what I'm asking is why does $RANDOM not work when using !# /bin/sh in the header?
# 4  
Old 10-10-2010
What shell do you usually use $RANDOM in? You should put in that shell instead of #!/bin/sh. On many platforms, /bin/sh is a very basic, minimal shell. Try 'echo $SHELL' inside your "good" shell to find out what it is.
# 5  
Old 10-10-2010
If you have to stick with /bin/sh, you could use /dev/random as discussed here: Random Number with /bin/sh - Linux / UNIX Forum

Edit:

If you want to pick a value between 0 and 32767 (like the ksh/bash RANDOM does) then this is what you want:
Code:
echo `od -v -An -N2 -td < /dev/urandom`/2 | bc


Last edited by Chubler_XL; 10-10-2010 at 09:34 PM.. Reason: Added 0-32767 solution
This User Gave Thanks to Chubler_XL For This Post:
# 6  
Old 10-10-2010
Thanks chubler, makes sense to me going to test it out right now
# 7  
Old 10-10-2010
The fact the you state that /bin/sh is a Bourne shell would suggest that you are not on a GNU/Linux platform. In that case you may not have a /dev/random or /dev/urandom.
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Server Staus offline to online -Shell script

Hi, We put cron entry :whenever server is offline(checks every 5 minutes) it sends status to mailer group. The number of messages (offline)were growing in our mailbox.How to avoid not to send offline messages after the first one through shell script. Thanks in advance. Chowdary (2 Replies)
Discussion started by: chowdary_m
2 Replies

2. UNIX for Dummies Questions & Answers

Online UNIX emulator for Korn Shell scripting

Hi, I am very new to UNIX and I wanted to know if there is any online UNIX emulator in which I can practice Korn shell scripting. I have internet access, but my machine's OS is Windows XP. I just had my UNIX fundamental class and wanted to practice some shell scripting. I am not in a position to... (1 Reply)
Discussion started by: eswasas
1 Replies

3. UNIX for Advanced & Expert Users

command for CPU online/offline status in bash shell

Hi , How do i check that the CPU is online/offline in a multi CPU machine in Linux ? i tired /proc/cpuinfo dmesg nothing gave me the currect CPU status. Pls help !! (5 Replies)
Discussion started by: sars
5 Replies

4. UNIX for Dummies Questions & Answers

how to display the shell type

hello, I was wondering what is the command to display the shell type? much thanks (3 Replies)
Discussion started by: yipster
3 Replies

5. Shell Programming and Scripting

Online/downloadable Shell Scripting book

Greetings All!! I am looking out for a comprehensive shell scripting book (unix & linux). I would request you to kindly post the links to get donwloadable/online books. I would prefer for the "Linux and Unix shell programming" by David Tansley. Any help will be highly appreciable. Cheers ... (5 Replies)
Discussion started by: arminder
5 Replies
Login or Register to Ask a Question