Software :: IP With Padded Zeroes In Bash?
Oct 28, 2010
To create a weblink I needed to pad zeroes to an IP Because I couldn't find any examples I created my own.I invite anyone to improve on it and hopefully I'll see many alternatives.I'm using 'grep -o' to break down the 4 segments....
Code:
# IP=127.0.0.1
# PADIP=`echo "${IP}" | grep -o -E '([0-9]*.|[0-9]*)' | awk '{printf( "%03d
", $1)}' | tr '
' '.' | sed 's/.$//'`
# echo ${PADIP}
127.000.000.001
View 7 Replies
ADVERTISEMENT
Jun 9, 2011
I am new to using 'pragma pack' and here is what I am running into :
Process A:
a.h -> defines a struct XYZ as PACKED and is of size 44bytes
a.c -> includes a.h and is able to print the size as 44 bytes.
Process B
b.c -> includes a.h,
b.c -> gets a message from process A, with struct XYZ in the message as data.
b.c -> After getting message, it is unable to print the elements of struct correctly. This is because the sizof (XYZ) in b.c is seen as 48 bytes.
I suspect, in b.c, the local variable of struct XYZ is being padded and not PACKED.
View 4 Replies
View Related
Nov 18, 2010
I'm writing a script that among other things partitions and formats disks using SW RAID and LVM. I've read somewhere that for older versions of Linux it was a good idea to use the dd command to zero the first couple of blocks od a device before partitioning it (or formatting it?) Is this practice still recommended? To what end?
View 1 Replies
View Related
Jun 5, 2010
I found a script that counts down to a date and time and after modifying my .conkyrc file I want things to line up nicely, so, now I need leading zeroes on the output, like one timer I have says "4m +2w 5d 20:0:0" and I want it to say "04m 02w 05d 20:00:00" and on a slightly separate issue, it doesn't seem to be counting the minutes and seconds correctly, but that can be dealt with later, the current script is
Code:
#!/usr/bin/perl
#Script Name: howLong.pl
#Author: Nathan Handler <nhandler @ubuntu.com>
[code]...
View 9 Replies
View Related
Sep 18, 2010
I have an external 500GB USB drive that I want to sell. I've copied some stuff to it and practiced partitioning and formatting with it, but I want to use something to erase it completely. Is this possible if the USB is connected to a ThinkCentre 8187-EJU with an Ubuntu 10.04 OS? I've used Dban to erase regular hard disks but don't any software that could be installed on my computer that would erase a USB drive.
View 5 Replies
View Related
Mar 9, 2011
I want to view a hard drive and see if it has all zeroes, how would I do this? I want to view a hard drive and see if it has all random data, or random data mixed with zeroes. How can I do this? I prefer to do all this in linux if possible without a gui...so looking for any cli tools to view with.
View 5 Replies
View Related
Feb 4, 2011
I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.
View 3 Replies
View Related
Nov 29, 2010
I create a bash script that writes another bash file. But in the generated bash file I want to write a bash command in the file and not executing it.Here's my bash file:
Code:
#!/bin/bash
cat > ~/generateGridmix2data.sh << END
[code]...
View 6 Replies
View Related
Jul 17, 2010
below are the details of my system. I have bash as my current shell, some really common commands aren't working.
Do I need to do a re-installation of bash? Or how do I install a selection of bash commands which I need? (for example a subset of [URL])
Code:
root@sdptfw:~ # uname -a
Linux sdptfw.sdpt.co.za 2.4.36 #1 Tue Jul 22 13:13:24 GMT 2008 i686 i686 i386 GNU/Linux
root@sdptfw:~ # echo $SHELL$
/bin/bash$
[Code]....
View 13 Replies
View Related
Jan 24, 2010
simple bash code:
Code:
#!/bin/bash
trap "echo 'you got me'" SIGINT SIGTERM # to trap ctrl+c
echo "Press ctrl+c during 5 sec loop"
for ((i=0;i<5;i++)); do
[Code]...
How come code behaves normally and stops when ctrl+c signal is caught and resumes, but after I use at least one timeout read in the code it looks like, if signal is caught again it doesn't pause the execution but skips the loop. If you remove -t (timeout) option from the read, both loops look the same!
View 10 Replies
View Related
Jun 5, 2011
I got a problem with terminal, since i'm really a noob with terminal i don't know how to fix it.Everytime i type in a command it shows for example:
-bash: ls: command not found
Even the basic commands don't work... just cd <directory> and those things works
View 9 Replies
View Related
Nov 26, 2008
I have a config file that contains:
my.config:
Code:
Now in my bash script, I want to get the output /home/user instead of $HOME once read. So far, I have managed to get the $HOME variable but I can't get it to echo the variable. All I get is the output $HOME.
Here is my parse_cmd script:
Code:
View 3 Replies
View Related
Jul 25, 2011
I have written quite a few separate bash & scripts and php scripts that up to now I have run from cron jobs. However I have to estimate how long each takes to run, before running the next and so it probably takes much longer than necessary to run them all. They have to run in order.
Now there are so many I am thinking it would be better to have a master bash script that would run one after the other, but I am not sure how to get the master script to wait before starting to run the next script. Is this possible and is there a command that will make the script wait between bash and php scripts , for them to finish, before running the next?
View 5 Replies
View Related
Jan 13, 2011
I have searched and searched and maybe I don't know how to articulate this issue with out just posting the problem I'm having. Every time I bring up a terminal window I get the following "Header"
declare -x COLORTERM="gnome-terminal"
declare -x CPLUS_INCLUDE_PATH="/usr/lib64/qt/include"
declare -x DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-xSFd6zqrYQ,guid=dc5e07974559da016842742900000090"
declare -x DISPLAY=":0.0"
[Code]...
To be honest I cheated and used the .bashrc / .profile files from Ubuntu and all was working fine for a while now and it seems something changed to cause this... any ideas on why I am getting this? I checked my .bashrc and my /etc/profile and it doesn't look like anything is amiss..
View 3 Replies
View Related
Jan 9, 2010
I would like to get the filename (without extension) and the extension separately. The best solution I found so far is:
Let FILE="thefilenameofsomefilesfor_instance.txt"
Code:
NAME=`echo "$FILE" | cut -d'.' -f1`
EXTENSION=`echo "$FILE" | cut -d'.' -f2`
I think it would be better to count the len and remove 3 chars to right to get the extension, but it can be macintosh filenames with have 4 chars for extensions.
View 5 Replies
View Related
Apr 28, 2011
I've noticed something, and hoped there was a work around.when I write a simple bash script, and run it, if I close the terminal i ran the bash script inside, the bash script stops. What are the solutions for this? Basically I want to run my bash script and close the terminal, keep the bash script running.
View 6 Replies
View Related
Dec 3, 2010
What happens when the script executes is that the ssh connection works and parks me at the remote hosts's shell login. Therefore, the "firefox" command refuses to execute. I need to know how to make the "ssh" connection occur, stay open, and go into the background so that the rest of the script can execute.If I could also do this with the "firefox" line so that the entire term window could be closed would also be helpful.
View 3 Replies
View Related
Jan 29, 2011
I am trying to write a bash script that sources another bash script. Essentially, I need a few lines to check to see if a certain variable is set. If not, I set it manually, and then source a scripts with that variable in the path. I wrote a test script to try it, but for some reason the last line does not work. Here is what I wrote:
#!/bin/sh
source ~setupdir/setup.shrc #just a test, this line works
echo ${#SETUP} # prints 0 if setup is not set, which it isn't
if [ ${#SETUP} -eq 0 ]
then
SETUP="~setupdir"
fi
echo $SETUP # prints ~setupdir
[Code]...
View 5 Replies
View Related
Dec 8, 2009
On one of my servers I see this when I log in. What does this mean and how can I get it to go away? Everything seems to work fine, but none of my other machines give this error.
View 5 Replies
View Related
Aug 27, 2010
why can't I use bash?
Code:$ bash To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details. $ /bin/bash To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details.
View 2 Replies
View Related
Sep 21, 2015
I have a virtual server with debian and since last Friday a problem. The server is running normally. All sites hosted show no problems. But If I logon via ssh is the CPU usage of all cores goes to 100%. A simple cd (change dir) then takes about 90 seconds. using top or htop bash is the top scorer. Unfortunately I have absolutely no approach what I have to change here or where the misconduct comes from.
View 2 Replies
View Related
Jan 9, 2010
This gives a selection menu where you choose an option, and it should continue. I have several of these as part of a much larger script, but something is wrong with this while loop.
Code:
VARIABLEINPUT="1"
if [ $VARIABLEINPUT == "1" ] ; then
echo -e "${YELLOW}How often would you like the automatic update and maintenance to occur after the installation?:
${RED}1)${WHITE} Hourly
${RED}2)${WHITE} Daily
${RED}3)${WHITE} Weekly
${RED}4)${WHITE} Monthly
"
[Code].....
A very simple loop that uses a variable from earlier in the script to adjust variables for later in the script. For some reason, this while loop will not end - I've noted where with echos.
View 4 Replies
View Related
Jul 8, 2010
anyone out there using and fluent in win-bash?
View 1 Replies
View Related
Apr 20, 2011
I wanted to change my $PATH and my prompt, had some trouble with setting and exporting the variables and found that the shell was csh instead of the bash which I expected. I worked around it by creating a .cshrc which calls bash but don't know what caused the change. I've got as far as seeing that the gnome-terminal command kicks it all off from the Applications>System Tools menu but what happens between there and the terminal popping up?
View 3 Replies
View Related
Mar 18, 2010
Im used to using nautilus within centos but have recently just got a VPS and quickly realising that using a KDE is unacceptable in this environment. Although I do find it so much quicker doing things like folder permissions in KDE rather than typing it all out in the terminal? Everyone I speak to says, use the terminal and I should learn this way as opposed to using the KDE, but theres certain things I just dont get
How is it possible to make quick changes to scripts and viewing them in a browser etc , without a mouse or using KDE? and only using a terminal?? I am wondering how to develop websites just using the terminal?
How can it be quicker to type out/view permissions etc in the terminal when its instant and just a few clicks in the KDE?
View 3 Replies
View Related
Sep 14, 2011
What is the difference between &> and >& in bash? tldp did not mention the latter one. Is it really a redirection operator?
View 3 Replies
View Related
Mar 17, 2010
I'm trying to use awk in a bash script. The line that is giving me grief is:
Code:
num=633674
x_orign=3000000.0
x_coordinate=$(awk '{if ($1==num) {print $3}}' file.txt
difference=$(echo $x_origin - $x_coordinate | bc -l)
[Code].....
How can I place both these results into a bash variable? Or into an array, etc?
View 2 Replies
View Related
Mar 28, 2010
I'm making a script I want to be able to just call (ie, rclick instead of ./rclick) where do I put it?
~/bin?
/bin?
/usr/bin?
Also, how do I pass a variable to the script (rclick 10 will rightclick 10 times) (Found, so simple... $1)Lastly, can I force it to run on CPU2? CPU1 is completley locked up if I run this on it... Or can I make it use less cpu cycles?
View 2 Replies
View Related
May 1, 2010
I would like to make a bash script that shuts down. Problem is... How am I supposed to do this when shutdown requires sudo and ultimately requiring me enter my password as a response?
I.e.
#/bin/bash
#Do: shutdown at xx : xx time
shutdown 23:45
#done (yea just one line...)
How could I make sure my password is given to the sudo response without manually entering it ever time?
How could one make this script run automatically i.e. on startup every time.
View 2 Replies
View Related
Jun 9, 2010
My ubuntu system hangs uppon start, think it has to do while my computer ran out of battery when installing updates. Is there way to do a safe boot so I can try to run:
sudo apt-get install --fix-broken
View 5 Replies
View Related