Adding a while loop to my script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding a while loop to my script
# 1  
Old 12-15-2011
Adding a while loop to my script

I have a script below that goes to the given directory and plays the newest powerpoint presentation via powerpoint viewer and wine.
So far it works perfectly but now Id like to add a while statement to essentially run
Code:
find /ticker/powerpointshare -mmin -1 -type f -iname "*.ppt"

and if it finds a file then execute the top half of my script again.


Code:
#! /bin/sh

# Start the newest Powerpoint presentation

# Change Directory to /ticker/powerpointshare
cd /ticker/powerpointshare

# Creates the variable newppt for use in this script
# ls -tr sorts the the ls output and pipes in into tail to grab the newest file 
newppt=$(ls -tr | tail -1)

echo This is the newest powerpoint presentation
echo $newppt
cd /ticker/powerpointshare

# We use wine to open the powerpoint presentation  with Powerpoint Viewer 2007
wine "C:\Program Files\Microsoft Office\Office12\PPTVIEW.EXE" /N $newppt

exit

# 2  
Old 12-15-2011
How would it know when to stop? Wouldn't it just run powerpoint over and over?
# 3  
Old 12-15-2011
Quote:
Originally Posted by Corona688
How would it know when to stop? Wouldn't it just run powerpoint over and over?
I was thinking of killing the process if it finds something and regarding the powerpoint its meant to play in a loop until it finds a new powerpoint presentation
# 4  
Old 12-15-2011
Some basic

If you want infinity times, each ten seconds. I suposse your ppt has a limited duration and prompt automaticaly when finish.

Code:
#!/bin/ksh
while true
do
./your_script.sh o your code
sleep 10
done

# 5  
Old 12-20-2011
Quote:
Originally Posted by binary-ninja
I have a script below that goes to the given directory and plays the newest powerpoint presentation via powerpoint viewer and wine.
So far it works perfectly but now Id like to add a while statement to essentially run
Code:
find /ticker/powerpointshare -mmin -1 -type f -iname "*.ppt"

and if it finds a file then execute the top half of my script again.


Code:
#! /bin/sh

# Start the newest Powerpoint presentation

# Change Directory to /ticker/powerpointshare
cd /ticker/powerpointshare

# Creates the variable newppt for use in this script
# ls -tr sorts the the ls output and pipes in into tail to grab the newest file 
newppt=$(ls -tr | tail -1)

echo This is the newest powerpoint presentation
echo $newppt
cd /ticker/powerpointshare

# We use wine to open the powerpoint presentation  with Powerpoint Viewer 2007
wine "C:\Program Files\Microsoft Office\Office12\PPTVIEW.EXE" /N $newppt

exit


Any idea why this script wont execute via cron on my ubuntu box?
# 6  
Old 12-20-2011
The same reason lots of things don't run in crontab according to our FAQ, a much more minimal environment than you get from a login. Try setting PATH to a more complete value yourself, or sourcing /etc/profile
# 7  
Old 12-20-2011
Quote:
Originally Posted by Corona688
The same reason lots of things don't run in crontab according to our FAQ, a much more minimal environment than you get from a login. Try setting PATH to a more complete value yourself, or sourcing /etc/profile
By full path do you mean that I should try to give it the full path to execute wine from the script above?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help on Adding one counter loop at the end of each line in a file

Hello All, I have file a.txt I want to add a counter loop at the end of each line in a file ill explain: i have a site h**p://test.test=Elite#1 i want to add a a counter to the number at the end of the file, that it will be like this urlLink//test.test=Elite#1 urlLink//test.test=Elite#2... (3 Replies)
Discussion started by: nexsus
3 Replies

2. Shell Programming and Scripting

adding one more column in a loop

data1 1 0.01 3 5 1 0.6 2 1 data2 2 0.02 3 5 2 0.3 2 1 data3 3 0.01 3 5 3 0.01 2 1 output 1 0.01 data1 2 0.02 data2 3 0.01 data3 3 0.01 data3 I want to print 1st, 2nd column and the filename when second column is less than 5. (3 Replies)
Discussion started by: johnkim0806
3 Replies

3. Shell Programming and Scripting

Bash: adding commas in for loop

Dear Experts I think this is possibly the easiest thing. but I am not able to solve: I need comma to be added to end of each line echo'd. But does not want it to be added to last line. I have a script which does some data analysis and creates a command as in below code snippet for... (4 Replies)
Discussion started by: chakrapani
4 Replies

4. Shell Programming and Scripting

Help needed: Adding columns in csv file in loop

Hi Everyone: My shell script creates multiple csv files (~30) in for loop. I want to compile (or merge) 3rd column from each (all) of these files to another file (in loop). Please help. Thanks. (3 Replies)
Discussion started by: smap007
3 Replies

5. Shell Programming and Scripting

adding counter to a variable while moving in a loop

The scenario is like this : I need to read records from a file one by one and increment counter1, if a certain field matches with a number say "40"..the script should increment the counter2 and also extract a corresponding field from the same line and adding them one by one and redirecting the the... (5 Replies)
Discussion started by: mady135
5 Replies

6. Shell Programming and Scripting

Adding string variable dynamically in for loop

Hi, I need to generate the text name dynamically in for loop, ex, VAR_COPY_FILE1= file path 1 VAR_COPY_FILE2= file path 2 VAR_COPY_FILE3= file path 3 for i in 1 2 3 do if then "do some process here" fi done (3 Replies)
Discussion started by: msubash26
3 Replies

7. Shell Programming and Scripting

doing a for loop adding up the results

Hi there If I run a 'swap -l' on my solaris box, i get swapfile dev swaplo blocks free /dev/dsk/c1t0d0s1 54,65 8 67119560 65655144 /dev/dsk/c1t0d0s2 54,65 8 33119522 32655122 I wanted to run a for loop adding up the totals of each column 4 , excluding the... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

8. Shell Programming and Scripting

Adding a Fileinput loop to exsiting script.

:confused: I'm very confused on what I need to do. I've looked at if, while, but I can't seem to visualize where in my current script to put the commands. I'm looking to read a directory /ERD/iface/data/ocom/citi/idd because there will be multible files, but I need to process them one at a time.... (2 Replies)
Discussion started by: netmad0
2 Replies

9. Shell Programming and Scripting

adding values with a loop

Hi there, I am checking disk spaced used on a box # df -k | grep dsk | awk {'print $3'} 2055463 20165785 18310202 32274406 I want to somehow add them up but am no quite sure how to do this in a loop. ...i.e for n in 'df -k | grep dsk | awk {'print $3}' do <some adding... (1 Reply)
Discussion started by: hcclnoodles
1 Replies

10. Programming

adding variables for, for loop

I have a structure which contains n number of elements. For example: stFruits : apple, grapes, strawberry, pear, kiwi, melon, papaya, mango, orange, sweetlime ..... etc Now i have to write a for loop as follows: int i; int j; j=stFruits.apple+stFruits.grapes+stFruits.pear+.... and so... (3 Replies)
Discussion started by: jazz
3 Replies
Login or Register to Ask a Question