Linux-wget command for certain time - wget

I am using wget command for download in terminal
Is there an option in the wget command that the download starts at a certain date and time?
Thanks

Is there an option in the wget command that the download starts at a certain date and time?
So far I know no, you might use at to launch any command at predefined time. Simple example usage: download https://www.example.com at 12:00
echo "wget https://www.example.com" | at 12:00
Note that you need to activate atd (daemon, see linked article) before using at. If you want to know more about possible ways of specifying time read man page of at.

Related

How to capture iPhone app debug logs

I was researching libimobiledevice to basically capture the specific iPhone app logs. I have tried with the idevicesyslog command, but it gives me all the system logs along with my app.
I tried with idevicesyslog -d | grep com.example.Example but does not give me the info I am looking for.
I am interested in the debug logs of my app.
I know there is a way to capture it from the organizer in Xcode but I don't want to do it that way. I am planning to do it programmatically and then integrate with Appium automation script.
I was able to achieve this with idevicesyslog -d | grep '"https://ac.XYZ.COM" >& t' write to the file "t" and then clear the file and move on to the next step.
This I was able to achieve but the only issue I am facing here is that I need to update the command, like it wont write to log on real time basis when I am interacting with the device. If someone can suggest a way where it log to the file in a real time that would be great.
You can use -m option from idevicesyslog, this option is for "only print messages that contain STRING"
Example:
idevicesyslog -m "Vantage"
Hope this method is work for you :)

How to increase one hours current date in DEC UNIX 4.0?

I need to add one hours to current date in DEC UNIX V4.0?
I tried "date" command but in this version of that command "-v" or "-s" and etc switch doesn't work.
for example:
date -s "5 seconds"
doesn't work.
I assume you have already read the DEC manual page and observed that there is no option that matches the -v or -s options in GNU date. From that, you will conclude that you'll have to write your own code or get someone else's already written code to do the job — and you'll conclude that installing someone else's working code is easier than writing your own code.
The simplest fix, therefore, is to install GNU coreutils and use the date command from that. Of course, there are some tricky bits to deal with. You'll probably not want to install the GNU date command in /bin or /usr/bin because that might break other scripts that expect the DEC version of the date command (it probably won't, but it might, and you're likely to be cautious — if you weren't cautious, you wouldn't still be using DEC UNIX). So, you probably need to add it to /usr/local/bin, or maybe you create a new directory such as /usr/gnu/bin (add --prefix=/usr/gnu to the ./configure command when you build the core utilities). And then you ensure that the commands that need to use GNU date reference it explicitly. (Commands that don't insist on using GNU date should continue to use DEC date.)

VLC command to stop recording a stream

First of all, thanks everyone who is even reading this.
I'm able to save a stream from my IP CAM into a file using the given command (although I'm getting no audio recorded to the file, if anyone can help with that would be great too)
cvlc "http://***.***.*.***:****/videostream.asf?user=admin&pwd=**&rate=12&resolution=32" --run-time=10 --sout="#std{access=file,mux=asf,dst=path\test.asf}" vlc://quit --qt-start-minimized --no-qt-notification
This gives me a 7~8 seconds long recording, but the lenght of the video I want to make will be determined by an external factor (the camera's motion detection alarm). If I remove the "--run-time" it starts recording undefinatelly, so how can I tell VLC that it's time to stop saving the stream?
ps: I want to make this automatic, so I'm only using command line.
ps2: I'm using Ubuntu OS.
Thank you all very much!
I'm by no means and expert on this subject but I am also capturing a live stream to start and stop at specific times. I don't know about the audio issue but here is my code maybe it will help you out somewhat.
at 2014-05-23 10:00
cvlc "http://*My url to video stream*" --sout file/mp4:*THEFILENAMEYOUCHOOSE*.mp4 --run-time=300 --stop-time=300 vlc://quit
Essentially I use the runtime and stop time switches to make sure it stops when I need it to, 300 seconds works out to almost an hour and a half of video so that's plenty for my needs, I'm having some trouble with being able to automatically script this so at this point I'm having to type the commands in by hand to set up the recording which is less than ideal.
Hope this helps you out even a little.
Later but if anyone is looking for the script, this my service in Debian/Ubuntu based compact recorder:
First, I create a bash script in /bin/usr/rec.sh
Put this script there whith sudo nano /usr/bin/rec.sh:
#!/bin/bash
while :
do
raiz=$(date +'/logger/%Y/%m/%d/')
saida=$(date +'/logger/%Y/%m/%d/%H%M%S.opus')
read min sec <<<$(date +'%M %S')
duracao=$((3600 - 10#$min*60 - 10#$sec))
duracao=60
echo "Starting new hour loging..."
echo "$saida"
echo "$duracao"
mkdir -p "$raiz"
vlc **your url here** --no-repeat --no-loop -I dummy --run-time="$duracao" --sout "#transcode{vcodec=none,acodec=opus,ab=64,channels=2,samplerate=48000,afilter=normvol,scodec=none}:std{access=file{no-overwrite},mux=ogg,dst='$saida'}" vlc://quit
echo "Done a hour logged!"
done
Make executable: sudo chmod +x /usr/bin/rec.sh
So, you need create a service Systemd for the script.
sudo nano /lib/systemd/system/rec.service
This sample help you:
[Unit]
Description=URL logger service
[Service]
ExecStart=/usr/bin/rec.sh
[Install]
WantedBy=multi-user.target
Reload systemd:
sudo systemctl daemon-reload
Enable and the service:
sudo systemctl enable shellscript.service
sudo systemctl start shellscript.service
check status:
sudo systemctl status shellscript.service
REMINDER: cvlc don't run as root by default. Here is the trick to do this:
sudo sed -i 's/geteuid/getppid/' /usr/bin/vlc
This service will record the url and transcode audio to OPUS in /logger directory, separated by YEAR / MONTH / DAY / HMS.opus (since record beggining). Each new file is started every hour o'clock.
I hope that help someone.
References:
https://tecadmin.net/run-shell-script-as-systemd-service/
and https://www.tecmint.com/run-vlc-media-player-as-root-in-linux/
Sorry my bad English.

How to stop the execution of .sh script at certain time?

I have the following script which ensure that a .php file will be invoked every 3 seconds.
#!/bin/bash
for (( i=0; i<43200; i++ ))
do
/usr/bin/php /var/www/vhosts/mydomain.com/httpdocs/somefile.php
sleep 3
done
I would like to be able to stop the script excecution if the time is 23:58:59
Anyone can help me?
Thanks, Zoran
case `date +%H%M` in 2359) break ;; esac
Edit: I discovered the zero padding in the date formatting string was not portable, so I took it out. It's not useful or necessary in this case anyway.
AGAIN me.
since your script has no imput youmcan try to launch yor script in the following way:
./yourscript.sh & sleep 10 && kill %1 && fg
give it a try.
Se
I think there is no direct way without using a scripting language like python or perl.
here if yo want there is te perl script already implemented:
http://www.cyberciti.biz/faq/shell-scripting-run-command-under-alarmclock/
Utilization summary:
Create a file installTimeout.sh containing the following:
wget http://pilcrow.madison.wi.us/sw/doalarm-0.1.7.tgz
tar -zxvf doalarm-0.1.7.tg
cd doalarm-0.1.7
make
and run the command:
source installTimeout.sh
now it's transparent to you.
When you want to give a timeout to your script yo just have to run:
doalarm 20 your script
Best,
Ste

Auto-complete command line arguments

In bash, executables such as mplayer and imagemagick's "convert" have a cool auto-complete functionality on their command line arguments. For instance, if I type
mplayer <tab><tab>
in one of my video folders, then mplayer will list all media files located in that folder, and only the media files.
Similarly, if I type
convert -<tab><tab>
then I will see all the possible options of the convert script, which is great.
My question is how to achieve a similar functionality, using bash, ruby or python scripts?
This is an example of BASH's smart completion. A basic description is here, a guide to writing your own extensions is here and another (Debian-based) guide is here. And here's a fuller featured introduction to the complete command (the command that facilitates this behaviour).
The link to writing your own extension in the accepted answer has gone dead. Quoting here from http://web.archive.org/web/20090409201619/http://ifacethoughts.net/2009/04/06/extending-bash-auto-completion/
Bash provides you a way of specifying your keywords, and using them to
auto complete command line arguments for your application. I use vim
as a wiki, task managemer and contacts. The vim helptags system lets
me index the content instead of searching through it, and the speed
shows it. One feature I wanted to add to this was to access these tags
from outside vim.
This can be done in a straight forward way:
$ vim -t tagname
This takes me directly to specific content marked using this tag. However, this will be more productive if I can provide
auto-completion for the tags.
I first defined a Bash function for the vim commandline. I added the
following code to my .bashrc file:
function get {
vim -t $1
} Now I can use get tagname command to get to the content.
Bash programmable completion is done by sourcing the
/etc/bash-completion script. The script lets us add our
auto-completion script /etc/bash-completion.d/ directory and executes
it whenever it is called. So I added a script file called get with the
following code in that directory.
_get()
{
local cur
COMPREPLY=()
#Variable to hold the current word
cur="${COMP_WORDS[COMP_CWORD]}"
#Build a list of our keywords for auto-completion using
#the tags file
local tags=$(for t in `cat /home/anadgouda/wiki/tags | \
awk '{print $1}'`; do echo ${t}; done)
#Generate possible matches and store them in the
#array variable COMPREPLY
COMPREPLY=($(compgen -W "${tags}" $cur))
}
#Assign the auto-completion function _get for our command get.
complete -F _get get Once the /etc/bash-completion is sourced, you will get auto-completion for the tags when you use the get command.
Along with my wiki I use it for all the documentation work and at
times the code too. I also use the tags file created from my code. The
indexing system lets me remember the context instead of the filenames
and directories.
You can tweak this system for any of the tools you use. All you need
to do is get a list of the keywords for your command and give it to
the Bash programmable completion system.
This functionality in bash is provided by bash-completion and similar functionality is included in zsh. If you want to add support for some program not currently supported by one of these tools, you need to write your own extensions for them.
How do I enable bash completion on Ubuntu?
sudo apt-get install bash-completion
source /etc/profile.d/bash_completion.sh
sudo apt i[TAB]