Questions Tagged With scriptinghttp://linuxexchange.org/tags/scripting/?type=rssquestions tagged <span class="tag">scripting</span>enWed, 04 Jun 2014 09:23:27 -0400FFMPEG How do I take a a screenshot from my desktop?http://linuxexchange.org/questions/3351/ffmpeg-how-do-i-take-a-a-screenshot-from-my-desktop<p>Hi, I want to take a screenshot of my desktop using FFMPEG, however I have no clue of how to set up a command like this and every time I search on google I only get how to extract a frame from a video... I ONLY want to take a single screenshot from my desktop using FFMPEG, so what is the command for that? Also, I am using ubuntu 12.04 LTS.</p>LinucNerdWed, 04 Jun 2014 09:23:27 -0400http://linuxexchange.org/questions/3351/ffmpeg-how-do-i-take-a-a-screenshot-from-my-desktopscreenscriptingubuntuBash Scripting Questionshttp://linuxexchange.org/questions/1464/bash-scripting-questions<p>Ok, I've got a basic bash scripting question, but the answer is so simple it eludes me.</p> <p>From my .bash_aliases file....</p> <p>PROBLEM 1:</p> <p><pre><code></p> <p># alias reboot-win-host='net rpc shutdown -S thehostname -U username -r -f -t 120 -c "This system will reboot in 2 minutes. Save any work now." &amp;&amp; echo Rebooting Remote Windows System' # alias reboot-win-ip='net rpc shutdown -I 111.111.111.111 -U username -r -f -t 120 -c "This system will reboot in 2 minutes. Save any work now." &amp;&amp; echo Rebooting Remote Windows System' #</p> <p></pre></code></p> <p>What variable(s) do I use for the hostname (or IP) and the username?</p> <p>I want to: $ reboot-win-host hostname-here username-here or $ reboot-win-ip ip-here username-here</p> <p>PROBLEM 2</p> <p>For these, I can't get them to work for whatever reasoning....</p> <p><pre><code> alias perm='stat -c '%A %a %n'' alias list-root-id='awk -F: '($3 == "0") {print}' /etc/passwd' alias install-date='ls /var/lib/dpkg/info/*.list -lht | tail -1 | awk '{print $6}'</p> <p>top 25 process/RAM usage alias top-proc='ps aux | awk '{print $2, $4, $11}' | sort -k2rn | head -n 25'</p> <p>Graphic connections to hosts alias hosts-connect='netstat -an | grep ESTABLISHED | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c \ | awk '{ printf("%s\t%s\t",$2,$1) ; for (i = 0; i &lt; $1; i++) {printf("*")}; print ""}' </pre></code></p>RonWed, 29 Dec 2010 22:43:24 -0500http://linuxexchange.org/questions/1464/bash-scripting-questionsbashscriptinglucidHow to get tighter codehttp://linuxexchange.org/questions/1339/how-to-get-tighter-code<p>I use an embedded terminal (Tilda) full time on my desktop, as I connect to my network of Ubuntu machines mainly thru SSH. I set up an update notification script that tells me update staus remotely, but it's kind o' clunky (I know my scripting skills are far from pro). Here's what I set up: </p> <p>Create a folder ~/.updates.<br> Create script called updates as follows: </p> <pre><code>#!/bin/bash # cat updates # A script to print out update status in bash # sudo apt-get update &gt; ~/.updates/updates.log sudo apt-get -s dist-upgrade &gt;&gt; ~/.updates/updates.log cat ~/.updates/updates.log | grep upgraded, </code></pre> <p>This does the job, but I'm sure it's far from optimal. Anyone have any suggestions on how to get it tightened up? This sort of thing is easy to do in some distros (Arch comes to mind), but Ubuntu is designed more for things like Update Manager and other graphical tools, so this was the best I could come up with so far. I want to be able to just get the line for available updates (for use in other scripts), not all the associated printout.</p>Dean ClemmonsTue, 07 Sep 2010 11:03:11 -0400http://linuxexchange.org/questions/1339/how-to-get-tighter-codeubuntuscriptingKickstart and customized Ubuntu installshttp://linuxexchange.org/questions/1251/kickstart-and-customized-ubuntu-installs<p>I'm looking at making a way where I can do installs of Ubuntu systems with as little work as possible.</p> <p>I'm just starting to use Kickstart so I want to do the unattended install; but I also want to have it pull the install-script.sh from the Internet (Dropbox right now, but maybe a PPA??) and then install some repos, applications, deb files for which there is no repo, and some wallpaper images, etc. I also want to be able to change, remove, update the install-scetup.sh on my Internet site and whatever deb files, images, etc, all at-will; -- so putting these things on the ISO image of the alternate install CD isn't really a viable option.</p> <p>By pulling from the Internet, I don't need to constantly update the CD itself until a new point release comes out, ala 10.04.1LTS, 10.04.2LTS, etc, so anything that I change (like adding/removing applications from the install-script.sh and/or *.deb files, wallpapers, etc) would instantly be updated. So of John installs and now a few months later I add some new backgrounds, remove a few applications from the install-setup.sh, so when Suzy installs, she will get those changes.</p> <p>It'd be a nice bonus if Johnny would get those changes too. I know that would require a PPA repo vs Dropbox. One thing about that though... I'm not a packager, so I don't know how to package *.deb files, etc.</p> <p>Some sites (and code....) I've ran across are below..... as for the code, will it work "as is"? How do I incorporate it into the ks.cg (Kickstart) file as a %post ? Can I even do that?</p> <p><a href="http://www.redhat.com/docs/manuals/linux/RHL-7.3-Manual/custom-guide/ch-kickstart2.html" rel="nofollow">http://www.redhat.com/docs/manuals/linux/RHL-7.3-Manual/custom-guide/ch-kickstart2.html</a> http://nerdnotes.org/2006/02/kickstart-for-ubuntu-live-cd/</p> <p><a href="http://www.ubuntugeek.com/unattended-ubuntu-installations-made-easy.html" rel="nofollow">http://www.ubuntugeek.com/unattended-ubuntu-installations-made-easy.html</a></p> <pre><code> #!/bin/sh # determine the mac address of the first network adapter mac=`/sbin/ifconfig | awk '/HWaddr/ { print $5 }' | head -1` # download and execute livecd init script wget -q -O - http://dl.dropbox.com/u/914191/install-script.sh?mac=$mac | /bin/sh </code></pre> <p>( Anyone who researches my posts on here will see the install-script.sh I'm talking about.) ( You can also get it at: <a href="http://dl.dropbox.com/u/914191/install-script.sh" rel="nofollow">http://dl.dropbox.com/u/914191/install-script.sh</a> )</p>RonThu, 19 Aug 2010 20:41:50 -0400http://linuxexchange.org/questions/1251/kickstart-and-customized-ubuntu-installslucidinstallscriptingkickstarthow to change dhcp-range using shell scirpt via Variablehttp://linuxexchange.org/questions/1153/how-to-change-dhcp-range-using-shell-scirpt-via-variable<p>Dear All,</p> <p>I have small query for Linux Shell Scripting , below is my requirement:</p> <p>I have configured dnsmasq.conf , and it is working fine , I want to create script which automatically change the configuration of sever based on small input from user:</p> <p>dhcp-range=192.168.4.200,192.168.4.230,2h </p> <p>From this line I want to change start range and end range by script,This IP will not be fix all the time so I can not use "192.168.4.200" in my script with sed , I want to put 192.168.4.200 (or any IP there on dhcp-range line with variable $startip) and 192.168.4.230 with (variable $endip) </p> <p>I tried using grep -o '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}' and also tried with awk but till now no success.</p>Chetan DiwaniTue, 27 Jul 2010 14:26:06 -0400http://linuxexchange.org/questions/1153/how-to-change-dhcp-range-using-shell-scirpt-via-variablelinuxscriptingbashProcessing passed arguments in scripthttp://linuxexchange.org/questions/1130/processing-passed-arguments-in-script<p>I'm trying to decide between short and long options, such as:</p> <p>-h </p> <p>vs.</p> <p>--help</p> <p>Obviously there are packages that deal with this, particularly in shell and perl programming.</p> <p>Getopts, Getopts::Std, and Getopts::Long</p> <p>I would prefer to use both, both -h and --help being a call for a help/usage function, but that requires quite a bit more effort.</p> <p>So my question is, what are the pros and cons of both, while I like the readability of the long notation, it's also nice and cleaner to be able to use just the simple single character flags.</p>rfelsburgFri, 23 Jul 2010 15:37:51 -0400http://linuxexchange.org/questions/1130/processing-passed-arguments-in-scriptprogrammingscriptingsystem-administrationbashconfigurationProgramming logic questionhttp://linuxexchange.org/questions/832/programming-logic-question<p>I'm looking for a high level view of how to get a program to tail a file continuously, not at intervals, and actually act on the data it has...whiles till continuously monitoring the file.</p> <p>I'm running into a mental block trying to figure out how to keep the program monitoring, which a while(1=1) loop would certainly accomplish, but how do you act on the data you've gathered, while still monitoring the file...</p> <p>If you exit the loop to act on the data, how do you still keep tabs on where you are in the file, it seems to me these need to be done in parallel...what am I missing?</p> <p>If you need a more concise or clear answer please let me know, I'm having a hard time getting my mind wrapped around this. Thoughts?</p> <p>Thanks,</p> <p>-Rob</p>rfelsburgThu, 10 Jun 2010 20:55:39 -0400http://linuxexchange.org/questions/832/programming-logic-questionprogramminglogsscriptinglinuxHow can I improve this install script?http://linuxexchange.org/questions/779/how-can-i-improve-this-install-script<p>This is a script I wrote that you can run right after you install Ubuntu 10.04LTS (Desktop Edition). It adds some 3rd party applications, repositories, configures iptables and so forth. One thing I'd like it to do is detect if it's being ran on a 32-bit or 64-bit system and then either download the w32codes or the w64codes accordingly.</p> <p>I'm also open to any other ideas and/or suggestions.</p> <p>I've updated this code a few times, incorporating suggestions from people to the point that there's more code than what I am allowed to paste here, si I've moved the code off-site to a Pastebin log at:</p> <p><a href="http://pastebin.com/3B9K5Fyp" rel="nofollow">http://pastebin.com/3B9K5Fyp</a></p> <p>1) Does anyone see anything else I can do too?</p> <p>2) Another thing I was thinking of adding was my own repository for files like fonts, images, PDFs, etc and loading them into the appropriate places .I do have a Lanchpad account, but I'm not a packager/programmer by nature. I'm a network / os / security guy, not a developer. I'd like to make some sort of all-inclusive *.deb file that people can download from my repo and it'd update wallpapers, documents, programs, etc.</p> <p>Right now as you can see, I'm using Dropbox as a repo of sorts.</p> <p>So in addition to my on-going question of how to improve the script and the above new things, I need to add this:</p> <p>3) Is there a way I can test my script without loading it onto a new PC? A sort of "simulation mode" per se?</p> <p>I've ran into a couple of issues where during the install, I must select choices (like to accept the EULA for Java, or to enable or disable a daemon, etc), and I'd like to automate that process somehow for testing purposes.</p> <p>Lastly, but most importantly, I'd like to thank everyone for their suggestions, as you have helped me make this a better script.</p>RonFri, 04 Jun 2010 17:43:13 -0400http://linuxexchange.org/questions/779/how-can-i-improve-this-install-scriptubuntuinstallscriptingbashlucidbash defeated??http://linuxexchange.org/questions/80/bash-defeated<p>Ubuntu Breezy 5.10 (don't suggest an upgrade - it works!)</p> <p>I'm trying to set up a script which updates some software on the hard drive from a directory on a USB Flash drive.</p> <p>After I've plugged in the USB drive and seen it recognised by automount:</p> <p>ls -l /vol/USBDISKB </p> <p>OK - shows me the directory and files.</p> <p>-BUT_</p> <p>#!/bin/bash if [ -d /vol/USBDISKB ]; then echo "Found USB drive" else echo "Not found: USB drive!" fi</p> <p>doesn't see the USB drive. :-((</p> <p>P.S. I tried to edit so it looks like code. Really.</p> <p>18/04/10 08:54 GMT Well! I don't know are am pretty stupid but I don't seem able to add a comment in response. All I seem able to do is edit my original post :(</p> <p>The obvious typos you can put down to my newbieness.</p> <p>If you are interested on following this question there has developed a much bigger thread here:</p> <p><a href="http://www.linuxquestions.org/questions/linux-software-2/bash-defeated-802372/" rel="nofollow">LQ Thread</a></p>fopeteslFri, 16 Apr 2010 10:55:41 -0400http://linuxexchange.org/questions/80/bash-defeatedbashautoloaderscriptingprogramming