<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Scripting on Jaymin Patel</title><link>https://jayminpatel.elemprin.com/tags/scripting/</link><description>Recent content in Scripting on Jaymin Patel</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sun, 15 Apr 2012 12:50:00 +0530</lastBuildDate><atom:link href="https://jayminpatel.elemprin.com/tags/scripting/index.xml" rel="self" type="application/rss+xml"/><item><title>English to Gujarati Dictionary in Linux</title><link>https://jayminpatel.elemprin.com/posts/2012-04-15-english-gujarati-dictionary/</link><pubDate>Sun, 15 Apr 2012 12:50:00 +0530</pubDate><guid>https://jayminpatel.elemprin.com/posts/2012-04-15-english-gujarati-dictionary/</guid><description>&lt;p>This post is for all Linux Desktop users from Gujarat who are looking for an English to Gujarati dictionary in Linux Desktop.&lt;/p>
&lt;p>In Linux, for English to Gujarati dictionary we open up a browser for an online database, but here we achieved it in just one tiny shell script.&lt;/p>
&lt;p>The constraint is that it requires internet connection as it uses an online database, but the good thing about this tool is that it has an updated dictionary database and it supports clipboard capture so we don't have to type a word each time.&lt;/p></description></item><item><title>Auto Logout in Linux</title><link>https://jayminpatel.elemprin.com/posts/2010-05-16-auto-logout-linux/</link><pubDate>Sun, 16 May 2010 11:41:00 +0530</pubDate><guid>https://jayminpatel.elemprin.com/posts/2010-05-16-auto-logout-linux/</guid><description>&lt;p>Almost everyone is forgetful and used to leave the Linux/Unix login session open without logging out. So, how to make sure all the Linux systems will automatically logout users after idle for certain minutes?&lt;/p>
&lt;p>In fact, the simplest way is to configure the &lt;strong>TMOUT&lt;/strong> shell variable!&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>export TMOUT&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#ae81ff">60&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This export command will immediately get the Linux OS to automatically logout a user after his/her login session being idle for 60 seconds or 1 minute!&lt;/p></description></item><item><title>Setup Proxy Setting in a Text-Based Linux Machine</title><link>https://jayminpatel.elemprin.com/posts/2010-05-16-proxy-settings-cli/</link><pubDate>Sun, 16 May 2010 11:32:00 +0530</pubDate><guid>https://jayminpatel.elemprin.com/posts/2010-05-16-proxy-settings-cli/</guid><description>&lt;p>In a generic scenario, internet access is running through a proxy in small offices. In that case, Linux command line utilities that require internet access to work like &lt;code>wget&lt;/code>, &lt;code>curl&lt;/code>, &lt;code>yum&lt;/code>, and &lt;code>apt-get&lt;/code> don't work. The questions that come up:&lt;/p>
&lt;ul>
&lt;li>How to install packages using proxy by yum?&lt;/li>
&lt;li>How to install packages using proxy by apt-get?&lt;/li>
&lt;li>How to download a file from command line using wget?&lt;/li>
&lt;/ul>
&lt;p>All these utilities depend on shell variables &lt;code>http_proxy&lt;/code> and &lt;code>ftp_proxy&lt;/code> to work with a proxy.&lt;/p></description></item><item><title>Argument List Too Long</title><link>https://jayminpatel.elemprin.com/posts/2010-05-16-argument-list-too-long/</link><pubDate>Sun, 16 May 2010 11:25:00 +0530</pubDate><guid>https://jayminpatel.elemprin.com/posts/2010-05-16-argument-list-too-long/</guid><description>&lt;p>Suppose, there are 1,30,000 files to move from one directory to another, what will happen?&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># mv *.txt test&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Oh!! There is an error:&lt;/p>
&lt;pre tabindex="0">&lt;code>mv: Argument list too long.
&lt;/code>&lt;/pre>&lt;p>What to do? Simple answer is to use find command:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># find . -maxdepth 1 -name &amp;#39;*.txt&amp;#39; -exec mv &amp;#39;{}&amp;#39; test \;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Here,&lt;/p>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>Option&lt;/th>
 &lt;th>Description&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>&lt;code>.&lt;/code>&lt;/td>
 &lt;td>Defines search directory&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>-maxdepth&lt;/code>&lt;/td>
 &lt;td>Disables recursive search. With &lt;code>-maxdepth 1&lt;/code> it will only search in current directory&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>-name&lt;/code>&lt;/td>
 &lt;td>String to be searched&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>-exec&lt;/code>&lt;/td>
 &lt;td>Applies a command to set of files that have been searched&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>{}&lt;/code>&lt;/td>
 &lt;td>Inserts each found file into given command after &lt;code>-exec&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>\;&lt;/code>&lt;/td>
 &lt;td>Indicates the exec command line has ended&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;p>The above example searches for &lt;code>*.txt&lt;/code> files in current directory and moves it to the test directory.&lt;/p></description></item><item><title>bad interpreter: No such file or directory</title><link>https://jayminpatel.elemprin.com/posts/2010-05-16-bad-interpreter/</link><pubDate>Sun, 16 May 2010 11:21:00 +0530</pubDate><guid>https://jayminpatel.elemprin.com/posts/2010-05-16-bad-interpreter/</guid><description>&lt;p>Sometimes shell scripts in Linux give this error:&lt;/p>
&lt;pre tabindex="0">&lt;code>bash: ./t1.sh: /bin/sh^M: bad interpreter: No such file or directory
&lt;/code>&lt;/pre>&lt;p>This happens when files are transferred from a Windows machine to a Linux machine. Different operating systems use different line ending characters:&lt;/p>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>OS&lt;/th>
 &lt;th>Line End&lt;/th>
 &lt;th>Character&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>UNIX/Linux&lt;/td>
 &lt;td>LF&lt;/td>
 &lt;td>&lt;code>\n&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>DOS/Windows&lt;/td>
 &lt;td>CRLF&lt;/td>
 &lt;td>&lt;code>\r&lt;/code> and &lt;code>\n&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Mac&lt;/td>
 &lt;td>CR&lt;/td>
 &lt;td>&lt;code>\r&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;p>&lt;strong>CR&lt;/strong> (Carriage Return): Return cursor to left margin, Ctrl-M (^M) or hex 0D
&lt;strong>LF&lt;/strong> (Linefeed): Move cursor down, Ctrl-J (^J) or hex 0A&lt;/p></description></item></channel></rss>