Ubuntu :: Calculations In A Shell Script?

Apr 21, 2011

I'm having some troubles with my backup script, i want to delete the folder that is 2 weeks old. The problem is that when is use the folowing code:

YEAR=(date +%Y)

Code:

#Remove old directories
TWOWEEKSAGO=$(date +%U)-2|bc
echo $TWOWEEKSAGO
#rm -r /home/[my home directory]/Backups/$YEAR/$TWOWEEKSAGO/

The $TWOWEEKSAGO variable is [empty] and not 14, but when I remove the -2|bc and I use:

Code:

echo $TWOWEEKSAGO-2|bc

It echo's 14.the weeknumber at this moment minus 2, I have to fix it when the weeknumber is 1 or 2 so the directory of the last year will be deleted, but I will fix that later if you don't know that.

Code:

#Remove old directories
TWOWEEKSAGO=$(date +%U --date='2 weeks ago')
rm -r /home/[my home directory]/Backups/$YEAR/$TWOWEEKSAGO/

After 30 minutes with some help I coded the following to delete the folders of last year:

Code:

#Remove old directories
TWOWEEKSAGO=$(date +%U --date='2 weeks ago')
if [ $TWOWEEKSAGO -eq 51 ]; then

[code]....

View 6 Replies


ADVERTISEMENT

Ubuntu :: Use Calc For Simple Calculations?

May 25, 2010

i am trying to use Calc for simple calculations. How can i do so that a whole column uses a number from previous row? for example i want D2=B2+C2+D1 and the next row to be D3=B3+C3+D2?

View 5 Replies View Related

Ubuntu Multimedia :: Feature In FFMPEG That Will Automatically Do The Calculations?

Mar 15, 2011

I have several videos (around 50) of varying resolutions aspect and varying aspect ratios that all need to be down converted to be playable on iOS and Android. Some videos are 4x3 some are 16x9 and some are 2.35x1. I want to write a script to convert all of these to a 360P version in one go. That means the 4x3 will be 480x360 the 16x9 will be 640x360 and the 2.35 will be 640x272.Is there a feature in FFMPEG that will automatically do the calculations for me?

View 9 Replies View Related

Fedora :: GSL For Scientific Calculations Configuration

Feb 26, 2010

Install GSL for scientific calculations. When you try to. / Configure appears Permishn denaynd. As I understand it because I have a file system in properties has Read-Only flag. An attempt to change it to read and write an error - saying that this can not be done. All this is done under Root. But nothing came of it, and very much need to put this library.

View 13 Replies View Related

Programming :: Calculations - High Resolution Mandelbrot - Working Code

Feb 25, 2010

I am piecing a Mandelbrot generator up, I have one working to produce a 1,500 x 1,500 picture (which is fairly accurate).

I would like to increase the resolution over 100,000 x 100,000 + (into the millions x millions).

How I can achieve this? What kind of buffer sizes do I need?

(note this code doesnt have any memory allocations yet)

Here is my code so far:

The program outputs the Mandelbrot as a .tga file. I calculated the image on fixed axis of -2 to 2 (on the x and y axis). Image produced: [url]

View 12 Replies View Related

Ubuntu :: Using 10.04-server 64bit AMD With Fluxbox - Matlab In A Shell The Shell Does Not Display Characters Anymore

Jul 26, 2010

I am using ubuntu10.04-server 64bit AMD with fluxbox. After I ran Matlab in a shell (without GUI) the shell does not display characters anymore, but will execute any command, I just can't see the characters that I'm typing.. I use aterm and xterm, does anybody know why that is, am I missing a package?

View 1 Replies View Related

Ubuntu :: Switch Desktop Shell From Unity To Gnome-shell?

Apr 14, 2011

Is there any way I can switch my desktop shell from unity to, say, gnome-shell? I can switch using other console shell I like (bash, csh, fish, etc.). Assume that there is a stable alternative desktop shell, I should be able to choose, too.

(For console shell, we goes to /etc/passwd. But for desktop, I can't find the way to config.)

View 2 Replies View Related

General :: $HOME/.bashrc Disabled When User Shell Is 'rbash' (restricted Shell)?

Jun 15, 2011

MACHINE: HP Proliant DL260G5OS: SLES 11 SP1kernel: Linux xserver 2.6.32.12-0.7-default #1 SMP 2010-05-20 11:14:20 +0200 x86_64 x86_64 x86_64 GNU/LinuxIt is used as remote xserver in a LAN.I have configured /usr/lib/restricted/bin/.rbashrc with some environment variables but when the users logon in the system finally is executed $HOME/.bashrc and some environment vars are overwritten.

View 2 Replies View Related

Fedora :: Stuck With Bash Shell / Changing Default Shell To Tcsh?

Mar 14, 2010

I want to change my default shell to tcsh. I used

Code:
usermod -s /bin/tcsh username
command as given at url

But if I open a new shell, it is still a bash shell.

How do I make my default shell as tcsh?

View 6 Replies View Related

Software :: Export A Variable To Parent Shell In Shell Scripting?

May 21, 2009

Is there a way to export a variable to parent shell in shell scripting ?

View 3 Replies View Related

Programming :: Shell Scripting / Create A Shell Script Similar To Ls?

Jun 5, 2011

I am trying to create a shell script similar to ls, but which only lists directories. I have the first half working (no argument version), but trying to make it accept an argument, I am failing. My logic is sound I think, but I'm missing something on the syntax.

Code:
if [ $# -eq 0 ] ; then
d=`pwd`
for i in * ; do
if test -d $d/$i ; then
echo "$i:"
code....

View 10 Replies View Related

General :: Write A Shell Script Instead Of Shell Function?

Apr 27, 2011

I would like know when it is necessary or advisable to write a shell script instead of shell function ?

View 3 Replies View Related

Programming :: Bash-shell-like Less Functionality In The Python Shell?

Jun 25, 2010

Is there some type of functional way to read things in the Python shell interpreter similar to less or more in the bash (and other) command line shells?

Example:

Code:

>>> import subprocess
>>> help(subprocess)
...
[pages of stuff to read]
...

I'm hoping so as I hate scrolling and love how less works with simple keystrokes for page-up/page-down/searching etc.

View 4 Replies View Related

General :: Open A New Shell From A Shell And Switch Between Them?

Jan 18, 2011

I am wondering if I can open a shell or new terminal thing from within the terminal in a unix/linux enviroment. Particularly a commandline only one where there is no GUI. Is this doable? how do I do it?

View 3 Replies View Related

Programming :: Prevent "leak" Into Shell From A Customized Shell Menu Script?

Dec 15, 2009

I've created a simple script based menu. This menu will be accessed by only a certain users via ssh.When user logs in, the menu will automatically run. (configured at user's .bash_profile).How do I force the session to close when user hits Ctrl-C or Ctrl-Break ?In a nutshell, I don't want user to have access to shell.

View 11 Replies View Related

Server :: Add To The Shell Script That Will Allow To Generate The File Using The Shell Script?

Jan 24, 2010

Quote:

/usr/local/bin/mencoder /root/video1.avi -of lavf -ovc lavc -lavcopts vcodec=flv:vbitrate=300:acodec=libfaac:abitrate=64 -srate 22050 -oac lavc -vf scale=360:240 -o /root/output_temp_video1.flv

[code]....

View 2 Replies View Related

Programming :: How To Turn Non-interactive Shell Into Interactive Shell?

Feb 4, 2011

I have a situation where I am in a non-interactive shell. I have tried from within my non-interative shell to spawn an interactive shell but my output still does not goto me. Isn't there a way I can somehow go into /proc or somwhere and make the output my /dev/tty1? Or some way else to remedy this?The situation arises because I drop from my restricted shell environment (a sort of CLI interface), into the actual Linux shell. I cannot change the code of the CLI environment I am just faced with being in the linux shell environment and its non-interactive. Its very annoying to have to put > /dev/tty1 after every command I type.

Not to mention it seems damn near impossible to get pagers like more and less to work properly when your in a non-interactive shell.

View 2 Replies View Related

Ubuntu :: How To Get It With Shell

Apr 7, 2010

there is a txt file :

["date"]1
["asset"]2
["cash"]3
["finance"]4

[code]....

what i want to get is :

["date"]0
["asset"]1
["cash"]2
["finance"]3

[code]....

how to get it with shell?

View 5 Replies View Related

Ubuntu :: How To Tell What Shell I'm Using

Jan 15, 2011

I wrote a script a while back that is supposed to be run in bash. It includes a hashpling (#!/bin/bash). Some people who are using the script are having problems with it however because they are forcing it to run in sh. They are doing things like:

Code:

sh script.sh

and

Code:

cat script.sh | sh

which ignores the hashpling and runs the script in sh, making the script fail half way through. How do I make my script determine the shell it's being run in and stop running if it's in /bin/sh?

PS: No, it's not

Code:

echo $SHELL

which has nothing to do with the shell you are currently in. No it's not

Code:

echo $0

which can be used in an interactive shell but does not work the same way in a script. No it's not

Code:

ps -p $$

as this will not work inside of a script the same way as it does in an interactive shell either. Those are the 3 methods that people keep describing when searching for the answer on google, and none of those works for what I need.

View 7 Replies View Related

Ubuntu :: Sed And Shell Scripting ?

Feb 22, 2010

I have recently put together an install script to make my life a little easier.

The server is using lighttpd and I wish for the auth mod to be enabled.

For the line:

I require the script to call the servers external IP and insert it in place of 127.0.0.1

View 5 Replies View Related

Ubuntu :: What Is 'login Shell'?

Jul 27, 2010

what is "login shell" and what is the difference between "login shell" and just "shell"?

View 2 Replies View Related

Ubuntu :: Does It Use Bash Or Some Other Shell

Sep 16, 2010

Does it use Bash or some other shell?

View 2 Replies View Related

Ubuntu :: Convert Jpg/png To Eps Within Shell?

Dec 20, 2010

I need to frequently convert jpg/png to eps. Usually I use GIMP and it works fine. I would like to perform the conversion via shell (maybe with a script) without opening any graphical window. I used the command convert of ImageMagick but the quality is poor, I assume that it is because of some parameter to set I do not know. I know the question is trivial and full of posts around but I'm wasting time without finding what I'm really looking for.

View 2 Replies View Related

Ubuntu :: Starting In The Shell?

Jan 1, 2011

How can I start up my Ubuntu Linux in the shell? Then how could I make sure to also get back to gnome?

View 1 Replies View Related

Ubuntu :: Running XP In A Shell In 10.10?

Apr 18, 2011

Basically I want to be able to run XP in a shell inside the Ubuntu environment (as opposied to just having duel install.

Is this possible? Stable? Realistic?

Its only for gaming really as I don't have all that much luck with Wine.

View 5 Replies View Related

Ubuntu :: How To Get Gnome Shell Looks Like Different

May 24, 2011

I installed Gnome 3 on Natty successfully, despite some minor glitches. It works fine, but recently I found some nice screenshots that looks quite different from which I get, and from others I saw before. You can found it in this link: [URL] Some one knows to what the differences are due?

View 2 Replies View Related

Ubuntu :: Cant Run Any Shell Script?

Jul 10, 2011

I have the natty version of lubuntu. i gave it permision to run as an executablei made the xterminalthe default application to open it.the shell script itself is ok because i started it in ubuntu and it worked.the shell script will only open as a text file.

View 9 Replies View Related

Ubuntu :: Alacarte Won't Start Up From The Shell

Jan 8, 2010

When I try to start alacarte from the shell, I get: Traceback (most recent call last):

[Code]...

The reason I start from the shell is because I noticed that it would crash after starting up in system monitor. This problem started after I tried to remove a program from the list which had already been manually removed. When this program was unchecked, the list went completely blank. I tried to revert the list, but it didn't work. Is there any hopes of repair?

View 8 Replies View Related

Ubuntu :: Run Shell Application From Browser?

Jan 24, 2010

I am looking for a method to run a shell script or open an application through the web browser.For example, open OpenOffice from the browser (without going through the menus).Is it possible?My ultimate goal to pass an argument through the browser to a script. I know it is pretty far fetched for my very limited abilities but I wanna try. For example I want to pass an URL or a text string from the browser to a shell script

View 9 Replies View Related

Ubuntu :: 9.10 Server - How To Use Bittorrent From Shell

Mar 8, 2010

I'm new to linux and try to make a ubuntu home server.1.One of my concerns is that i can't figure out how to use bittorrent (or any other torrent download application) from shell. (i have the desktop package installed but i don't wanne get used with that - or should i start the downloads from there but if I close the gdm (gdm stop) will my bittorrent stop as well?)

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved