Sponsored Content
Top Forums Shell Programming and Scripting Looking for help with a script to automate VLC Post 302321119 by uncertain on Saturday 30th of May 2009 08:22:35 AM
Old 05-30-2009
Looking for help with a script to automate VLC

Hi,
New member here looking for help. This might not be a post for the 'VERY basics' section, so feel free to move it to somewhere more appropriate.

I've created a script that searches my computer for video files, creates a list of these files, and selects a number of random entries to play in VLC. After a recent catastrophic external HDD failure, everything I could recover has been moved to two computers on a LAN. Now, instead of just searching my ~/Videos folder for the files to index and play, I have to search the ~/Videos folder of a second computer as well, index those (appended to the same list, preferably), and include them in the random shuffle I've created.

I have SSH & SCP access on both machines (I recently learned how to implement passwordless-ssh using rsa & dsa keyfiles, specifically so these processes could be automated). I don't have Samba or NFS installed or working on either computer, but I'll install and configure them if need be. (Though I'd rather not install, configure, and enable NFS or Samba, edit fstab, and then auto-mount a remote folder at boot just to do this.) Just today, I've learned how to start VLC on the remote computer in network-streaming mode, and then start VLC on the local host in network-capture mode. All I'm having a hard time conceptualizing is how to implement the indexing process from a script on the local machine to list files on a remote machine.

Here's a copy of my script in its' current state. It's the first BASH scripting project I ever tackled, and 'borrowed' bits & pieces of it from various things I found via Google. I'm sure there's a better/smoother/cleaner way to do some of the things I did, but it works, and I'm happy with it. Right now, it's set to index all the episodes of The Simpsons that are in my hard drive, and then play several random episodes.

If anyone could point me in a direction or give me some pointers, I'd greatly appreciate it.
Code:
#!/bin/bash
#
# Creates a list of all files in all Simpsons folders and then
# plays so many random episodes with VLC Media Player.
# Created by Uncertain

# Filenames and paths.
path1=/home/zero/Videos/
path2=/home/zero/Videos/Simpsons
list=/home/zero/Videos/Simpsons/episodes.txt
# Check for the list. If it's in ~/Videos, fine.
# If it doesn't exist, create it in ~/Videos.
if [ -f $list ]
 then
  echo "List found at $list"
   else
    echo "Episodes list not found. Creating list arranged by season & episode..." && cd $path1 && find ~/Videos/Simpsons -name '*.avi' -o -name '*.mpg' -o -name '*.mp4' -o -type f -size +20M | sort > $list && echo "Done. List created at: $list" 
fi
# Set the number of episodes to play. Episodes are 
# roughly 20 mins, so three episodes to every hour.
repeat=3
cycles=0
while  [ $cycles -ne $repeat ]
 do
  echo $cycles
  cycles=$(( $cycles + 1 ))
# Read the list, select one random line.
LowerBound=1
RandomMax=32767
UpperBound=$(cat $list | wc -l)
RandomLine=$(( $LowerBound + ($UpperBound * $RANDOM) / ($RandomMax + 1) ))
# Use sed to grab the random line.
episode=$(sed -n "$RandomLine{p;q;}" "$list")
# open the random line in VLC
vlc -vvv --fullscreen "$episode" vlc:quit
# Close the episode count loop...
  done
# ...and then...
exit


Last edited by uncertain; 05-30-2009 at 10:43 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

automate the input in a script

I have a program that i have to run by cron. The program needs user input. So i have to automate that in a littke script. start of script program.sh: result=program.log; export result echo Program starting : `date` >> $result /usr/local/program >> $result echo Program running : `date` >>... (11 Replies)
Discussion started by: erwinspeybroeck
11 Replies

2. Shell Programming and Scripting

here document to automate perl script that call script

I am trying to use a here document to automate testing a perl script however when the perl script hits a system(perl subscript.pl) call, input is no longer entered into this subscript. here is my script $ cat test.sh #ksh for testcase do program <<-EOF | tee -a funcscnlog.log y... (3 Replies)
Discussion started by: hogger84
3 Replies

3. Shell Programming and Scripting

Script(s) to Automate Tasks

I know that this has a bad title, but I'm not sure how to sum it up well. (And I'm new to Linux in general, so please excuse any incorrect terminology :o) Anyway, I'm trying to create a script that gets whatever folder you're in, and then does a command with that directory as an argument. I... (2 Replies)
Discussion started by: droppedonjapan
2 Replies

4. UNIX for Advanced & Expert Users

Shell Script to Automate

I would like to automate script where i do not have to manually insert the username and password I wrote two different scripts but not able to achieve the results: here's to scripts i wrote #!/bin/bash cd /var/tmp /home/server/steve/pca --askauth -idx /opt/app/bin/expect <<EOF expect... (1 Reply)
Discussion started by: sam786
1 Replies

5. Shell Programming and Scripting

Automate shell script

I would like to automate script where i do not have to manually insert the username and password I wrote two different scripts but not able to achieve the results: here's to scripts i wrote #!/bin/bash cd /var/tmp /home/server/steve/pca --askauth -idx /opt/app/bin/expect <<EOF expect... (3 Replies)
Discussion started by: sam786
3 Replies

6. Shell Programming and Scripting

Automate Script ***V. Urgent

Hi All, ./procdure.ksh which opens the below the menu, I want to build a script which will press 4 and run the Sector Data Automatically (instead of pressing option 4 manually) Is there any way for this, please let me know... 1) FX Rates MDU 9) Fidessa Cash... (7 Replies)
Discussion started by: niceboykunal123
7 Replies

7. Shell Programming and Scripting

How can I automate a script?

Hi All, Can I automate a script when some one trying to 'vi' (open) a file. For Example, I am having a file named 'SecuredShell.sh'. when a user types " vi SecuredShell.sh " in unix command prompt a script named secure.sh needs to be automated. Can this be possible. if Yes please guide... (2 Replies)
Discussion started by: little_wonder
2 Replies

8. Shell Programming and Scripting

mail script to automate

Hi, Here below the logs from the mail server: less /var/log/messages: Sep 6 04:03:31 server-59 out: 1252227811|webmaster@zilia.com|antonino.granata@gmail.com|2175|success|1 Sep 6 04:03:33 server-59 in: 1252227813|news@tarot.com|junk@thess.com|30376|success|1 Sep 6 04:03:35 server-59... (8 Replies)
Discussion started by: gsiva
8 Replies

9. Shell Programming and Scripting

Automate remote script

Hi all, I need to execute a script on a remote machine that are connected to the network.The basic requirement is to write a script which will login in remote machine and then execute the other script automatically placed in remote machine.So that I need to execute the remote machine script... (3 Replies)
Discussion started by: smartgupta
3 Replies

10. Windows & DOS: Issues & Discussions

automate the script

Dear all, I I want to login to my Linux machine using putty and then run some script from Windows machine.we can do it after loging it and then execute the script by typing it in putty command line screen. but I want to automate it.So whenever I will fire this script,it will do the following... (4 Replies)
Discussion started by: smartgupta
4 Replies
CDPLAY(1)						      General Commands Manual							 CDPLAY(1)

NAME
cdplay - play audio compact disks SYNOPSIS
cdplay [ -a]|[-r] DESCRIPTION
Cdplay is an audio-cdplayer it can be used interactively or non-interactively. With no flags cdplay is used interactively. When used inter- actively cdplay can be either in non-playing or playing mode. In non-playing mode you can select tracks to be played. In playing mode cdplay shows the track-time, remaining track-time, total-time and remaining total-time. Cdplay assumes the drive to be at /dev/cd0. During non-playing mode the following commands are available: cursor-up/down browse through the track-list spacebar add track to the play-list backspace remove a track from the play-list s start playing the tracks in the play-list. When the play-list is empty start playing from the current position in the track-list until the end of the cd p play the track on the current position in the track-list r play all tracks in a random order (shuffle play) e exit cdplay During playing mode the following commands are available: s stop playing, return to non-playing mode spacebar pause/resume current track cursor-up/down skip to next/previous track OPTIONS
When one of these options is used cdplay does everything in the background. -a Play all tracks, cdplay tells the drive to play all tracks and then it immediately returns to the user -r Play all tracks in random order (shuffle play). Cdplay forks of a new process which starts up a track, during that track it sleeps. When the track is finished it wakes up to start the next track and goes to sleep again. The parent process immediately returns to the user. BUGS
Cdplay does not sense if a cd has changed, so don't switch cd's. If you want to play another cd you have to insert the new cd and start cdplay again. AUTHOR
Michel R. Prevenier (mrpreve@cs.vu.nl) CDPLAY(1)
All times are GMT -4. The time now is 03:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy