Shell script wont execute


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script wont execute
# 1  
Old 09-09-2011
Question Shell script wont execute

Im using a script that writes a random line to a text file then executes another shell script. My problem is that the lottery shell script will not execute. Im not receiving an errors when running the shell script, and it copies a random line of text to mtest.txt fine.

Code:
#!/bin/bash

nscripts=2
rn=$(( ($RANDOM % $nscripts)+1 ))

case $rn in
    1) echo 'test1' >> mtest.txt;;
    2) echo 'test2' >> mtest.txt;;
esac

msg=`printf "./lottery.sh\r"`
exit

# 2  
Old 09-09-2011
Yes, of course. Because you don't run this script you just assign its name to variable "msg". And you don't use it and use unnecessary exit command.
Learn to use -x option and understand the output:
Code:
bash -x your_script

And do not try to write some fancy scripts before you get to work simpler ones.
# 3  
Old 09-09-2011
Quote:
Originally Posted by kylecn
My problem is that the lottery shell script will not execute.

Because you are not executing it. You are just assigning the output of printf to the variable "msg". ./lottery.sh snippet would do that.
# 4  
Old 09-09-2011
Well that makes sense. Im very new to shell scripting, and it doesn't help that i keep leaving and coming back to it.

Things are working appropriately now, back to messing around with different options Smilie thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

C shell script wont terminated if i don't modify the shebang

Hi all, I'm new to shell script i wrote some shell script for my colleague, everyone is fine,except on user we are using VNC viewer to work and there are some script start with shebang #! /bin/csh there is an user will not terminate after running the script even if a hello world i need... (5 Replies)
Discussion started by: pilistar0222
5 Replies

2. Shell Programming and Scripting

Startup script wont execute on NAS

Hi, So I've created /etc/rc.local #!/bin/sh polipo -c /opt/etc/polipo/polipo.conf exit 0 if I run it with ./rc.local it does what its supposed to do and the proxy starts but not at startup. any idea whats wrong? thanks (1 Reply)
Discussion started by: deon
1 Replies

3. Shell Programming and Scripting

Batch script to execute shell script in UNIX server

Hi team, My requirement is to transfer pdf files from windows machine to unix server and then from that unix server we should sftp to another server. I have completed the first part i.e From windows to using to unix server with the help of psftp.exe code: psftp user@host -pw password <... (1 Reply)
Discussion started by: bhupeshchavan
1 Replies

4. Red Hat

root crontab wont execute a script

Greetings/ I have a script listed in my roots crontab 07 9 * * * /opt/HLRSDATA_2010_OCT/HLRS_Scheduler_sp.sh > /opt/HLRSDATA_2010_OCT/logs/HLRTKJob.log This script contains the following #!/bin/bash echo HLRSData Scheduler cd /opt/HLRSDATA_2010_OCT /usr/bin/java -Xms32m -Xmx1024m -cp... (6 Replies)
Discussion started by: RedSpyder
6 Replies

5. Shell Programming and Scripting

Dos batch script to execute unix shell script

Can anyone help me with a dos batch script to execute a shell script residing in an unix server. I am not able to use ssh. Thanks in advance (2 Replies)
Discussion started by: Shri123
2 Replies

6. Shell Programming and Scripting

MKS KORN SHELL WONT EXECUTE from windows command prompt

Can anybody help me with this small script , the script works fine and launches the IE from c:\documents and settings \test\my documents>ksh prompt $RunURL1.sh this scitpt works and launches the ie from ksh , but when i schedule it to run the script then i get the error box saying command:1... (2 Replies)
Discussion started by: venu
2 Replies

7. Shell Programming and Scripting

How to use ssh execute other shell script on other host (shell script include nohup)?

i want use ssh on the host01 to execute autoexec.sh on the host02 like following : host01> ssh host02 autoexec.sh autoexec.sh include nohup command like follwing : nohup /home/jack/deletedata.sh & after i execute ssh host02 autoexec.sh one the host01. i can't found deletedata.sh... (1 Reply)
Discussion started by: orablue
1 Replies

8. UNIX for Dummies Questions & Answers

Tcl script wont run in bash shell

Hello I'm having a problem running a TCL script in my new OpenSolaris OS. When I go to the directory containing my script called 'Install' (using the gnome terminal), it doesn't seem to be able to find it even though it lists it i.e. if I type "Inst" and hit tab to complete the word, it... (11 Replies)
Discussion started by: sbsbg
11 Replies

9. Shell Programming and Scripting

Execute unix shell script to text file using the script

Hi all, I am beginner in UNIX...I want to use unix shell script to create text.file...I know how to use using by command...can anybody tell me for the script? Thanks i changed the threads title from "tex file" to "text file", because "tex" would probably be misunderstood as reference to... (4 Replies)
Discussion started by: mastercar
4 Replies

10. UNIX for Dummies Questions & Answers

file wont execute

sh filename and it gives me an error saying the file doesnt exist but it definately does. (4 Replies)
Discussion started by: iago
4 Replies
Login or Register to Ask a Question