Hello Guest, if you are reading this it means you have not registered yet. Please take a second, Click here to register, and in a few simple steps you will be able to enjoy our community and use our OpenViX support section.
Results 1 to 1 of 1

Thread: Scripting in the VU+ (based on Vti 2.2)

  1. #1
    bassethound's Avatar
    Title
    Forum Supporter
    Donated Member
    Join Date
    May 2010
    Location
    North West
    Posts
    5,719
    Thanks
    6,871
    Thanked 6,131 Times in 2,737 Posts

    Scripting in the VU+ (based on Vti 2.2)

    If you are new to this, you will need to research bash scripting and the cron timer, this tutorial assumes you know what they are.

    In the VU+ the environment variables that sets the link to dashboard from the command line file seems to be missing or not set properly. In the first instance change directories to the top level via the cd / command.
    ie. if you run a script like this:

    root@vusolo:/# ./myscript.sh {press enter}

    you will get:

    -sh: myscript.sh: not found

    This tells you that it is attempting to use -sh dashboard by default. However when the script is there and chmod 755 so that it is executable, then the -sh variable does not seem to be passed correctly.
    If you run:

    root@vusolo:/# /bin/sh myscript.sh {press enter}

    your script will run successfully.
    So now you can create a simple script, i'm going to put it in the root just for simplicity.
    Here is a sample script

    #!/bin/sh
    echo "micks updater"
    rm /var/whatever/myfile
    wget -O /var/whatever/myfile "http://www.wherever.com/lookup.php?file=theirfile"
    echo "Done!"


    Write this to a text based file and save it as myfile.sh , don't put any empty lines at the end, the bash handler in the VU+ interprets these as bad lines from root. (bash,dash,sh - are all dashboard like DOS command line interpreter the VU+ uses sh)

    The script tells the interpreter which dashboard to use - ie "sh"

    It then prints or echos to the telnet window "micks updater" so you can tell the script is running via telnet
    It then deletes the old file, because wget will not overwrite it.
    It now downloads the new file called "theirfile" and renames it "myfile" putting it in the directory I specified.
    It then prints or echos to the telnet window "Done"

    That is basically how to start scripting in the VU+

    Now how to add that to the cron sheduler
    How to do that?
    The easiest way by far is to create another text file called cronjob.txt and enter into it what you want it to do.
    for example:

    0 */12 * * * myscript.sh
    There must be 1 extra blank line at the bottom of this file (Unlike the script)

    This tells the scheduler to run myscript.sh from /root every day / 12, in other words every 12hrs. To load this ftp it to you boxes root. Telnet to your box and cd / to root dir and type:

    crontab cronjob.txt

    You can check the cronjob has been accepted by typing

    crontab -l

    It will show you what has been added to the scheduler. Note that adding a new file overwrites the scheduler so new file must contain entries for jobs you want to keep running

    Thanks to mickle
    __________________
    All PM,s asking about c/s on cable will be ignored and reported to forum staff!

  2. The Following User Says Thank You to bassethound For This Useful Post:

    Larry-G (08-01-11)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.