Ubuntu :: Defining Variables With Printf?

Mar 24, 2010

I am trying to use bash 'printf' to format an environment variable.Doing this I get on the screen just the format I need (underscores mean blank spaces):prompt> printf "%10s" "1.23"________1.23Unfortunately, when this is assigned to a variable, the format disappears:prompt> X=`printf "%10s" "1.23"`prompt> echo $X1.23Does anyone know what can be done in this case to get a proper format?Why does not 'printf' respect the left blank spaces when assigning values to a variable?

View 3 Replies


ADVERTISEMENT

Slackware :: Standard Location For Defining Environment Variables

Jan 4, 2011

I'm setting up Tomcat right now, and I've been directed to create a tomcat_home (catalina_home as of writing) environment variable.

Where is the default location for env variables in Slackware? My current inclination is to create a new script /etc/profile.d/tomcat.sh.

View 1 Replies View Related

Programming :: C-shell Scripting Syntax Error When Defining Two Variables A1 And A2

Apr 5, 2011

I am trying to modify a script for research purposes and am having difficulty here as I have little prior experience with C-shell scripting.

The script looks as follows (it includes tcl commands like runFEP that you can ignore)

#!/bin/bash

for ((old=1, new=2; old<=4; old++,new++))
a1=${old}%50
a2=${new}%50
do
cat > input${new}.conf <<EOF
${a1}
code....

My question: I keep getting a syntax error when defining my two variables a1 and a2. I essentially need these variables to be
a1 = value of variable old divided by 50
a2 = value of variable new divided by 50

View 1 Replies View Related

Ubuntu :: Bash Script With Variables And Editing Variables

Apr 6, 2011

mkvmerge -o <filename without extension>_TV.mkv -S <filename> && mkvextract tracks <filename> 3:<filename without extension>.*** && perl /home/brian/Desktop/ass2srt.pl <filename without extension>.*** && rm <filename without extension>.***

Doing these commands for multiple command line file inputs is the goal. So I can just type ./script.sh *.mkv in my terminal.This is what I have so far, but it doesn't work whatsoever.

View 2 Replies View Related

Ubuntu :: Redirecting Output From Printf Statement In C Program

May 22, 2010

I've got a C program that I've added some 'printf' statements to monitor a couple of variables. When I run this program manually or from a script, the output is displayed on screen. However, I need to change various variables in the 'test.c' file, run 'make clean' and 'make' a few hundred thousand times. I'm using a script to read the variables in and then using sed to do in-place edits of the file. Unfortunately, with this amount of iteration, it is getting rather tired!

Anyway, I've created a script that is working as long I respond to prompts. I've tried the following to no avail: Code: /path/to/script > /tmp/output /path/to/script > /tmp/output 2>&1 /path/to/script | tee (no output even after adding the -a option) In my C program, I have the following 'printf' statement: Code: printf ("variable1: $s variable2: $s",var1,var2); What am I missing? I've worked with redirection before and it's always worked out fine, but this one plain stumps!

View 2 Replies View Related

Programming :: Printf Is Printing To The File?

May 10, 2011

Id like to share with you a strange behavior I�ve been seen with the printf C language function running in Fedora.The code opens a file as showed:descString = fopen( strcat( stringName, txt), a+);There are also some printf functions in the code.However, instead of the printf functions to print their content at the screen, theyve been printing them in the file with the descString file descriptor.Have you ever seen something like that?To print something to the file I use the fprintf function. I didn't make a mistake to confuse printf with fprintf. I'm sure.

View 2 Replies View Related

General :: Printf Calls - Cost Of I / O Redirection

Dec 16, 2010

Some context: I'm calling some functions from within a C program and want to measure how long they take to execute. I've done this successfully, calling printf to print the results to the screen. This is reasonably fast. Ideally I'd like these to be dumped to a file, but fprintf presumably has some overhead since it writes to disk? Unless the data is buffered by the kernel and flushed later? What kind of delay can I expect before fprintf returns?

If I redirect the stdout to a file when I instantiate the binary as a process, will calls to printf also experience any overhead from redirection to a file? My aim here is to capture all data in a file, with the minimal amount of coding and effort, but with minimal impact in terms of time overheads for printf calls.

View 10 Replies View Related

Programming :: Bash Rounding Up Numbers With Printf

Feb 2, 2010

For eg: $NUMBEROFPASSES=6.19 to round up I use NUMBEROFPASSES=$(printf %.0f $NUMBEROFPASSES) What I need to do is round up from eg: 6.10 to be 7 and if lower than 6.10 round down to 6

View 5 Replies View Related

Programming :: How To Printf Long Data Type

Jun 7, 2010

misunderstood structure definition at the beginning

View 3 Replies View Related

Programming :: Printf() In C Being Able To Specify Foreground / Background Colors?

Nov 21, 2010

I got curious during the construction of my program to search for blocks of text that contain certain words, and wanted to print out blocks of text with the words I was searching for, initially, in ALL CAPS and seperated by tabs for easy identification. That got boring, though, so I thought, "Can printf do colors, too?" Yes it can.... Who knew?

[Code],,,

View 8 Replies View Related

General :: Printf White Space - Words Splitting?

Jun 15, 2010

I am having trouble keeping the name together and the phone number together, I think due to the white space. I have tried "" and '' it doesn't seem to matter. So it may be my syntax? and does it matter how long the first and last names are.

me$ echo 'fstname lstname' '123 123-1234' | ./myscript
#myscript
read a b
printf "%-15s %20s
" $a $b >> my_phone_numbers
OUTPUT

fstnamelstname
123123-1234
insted of
fstname lstname
123 123-1234

I know its not an elegant script but I am still learning how some commands work.

View 2 Replies View Related

Programming :: Get A Core Dump In One Of The C Library Calls (like Strcpy Or Printf)

Sep 20, 2010

I am trying to port some "C" code from Solaris to Linux. I have a Dell PowerEdge R610 with an Intel Xeon E5504 quad core processor running Red Hat Linux Enterprise 5.3. I am compiling in 64 bit mode. I have managed to get the code compiled and linked, but when I attempt to execute it, I get a core dump in one of the C library calls (like strcpy or printf.)

I have a static library that contains our own code that makes the call to the C library. If I move the library method into the source file with the main method and rename it to be certain that I am executing my method instead of the method in our library, the call succeeds. Eventually another static library call is made that results in a core dump in the shared object. I compile my library code into a static library with gcc as:

[Code]....

View 3 Replies View Related

Ubuntu :: Defining Custom Commands In .bashrc?

Apr 26, 2011

I'd like to know if there is a way to define commands in the .bashrc or .bash_profile. For instance, I want to be able to type 'work' in a terminal and set up an interactive work environment on my universities cluster. (This is done with the command 'qsub -I -X'.) I tried the following in my .bashrc file:

alias work ='qsub -I -X'

But, of course this failed, as I don't have a command work already defined. How do I go about doing this? Also, I can't assign 'qsub' an alias, since it's used with different options quite extensively.

View 5 Replies View Related

Ubuntu :: Defining Keys Under Compiz With Unity?

Aug 4, 2011

I'll come out and say I actually quite like unity, but it still needs a whole load of development. So I'm just wondering if anyone else knows how or why you can't bind Compiz keyboard shortcuts wile running unity. I'm trying to bind a shortcut (any) to Initiate a Window Picker for Window Group. If Unity is moving toward the Mac way of treating groups of windows that belong to the same program as an application it needs to have more options to manage those windows, being able to at least expose those windows would be a start. However I cant seem to put a keyboard binding for this function. I've tried <super>+<shift>+W and on a hunch that it was unity's Super that was messing it up <control>+<alt>+ and <super>+ and <alt>+W and <alt>+<shift>+W.

View 1 Replies View Related

Programming :: Defining Variable With Sed?

Jun 2, 2010

I need to replace JAVA_OPTS= with JAVA_OPTS=<some_value>.I need to give "" value at the end of the replacement. I have tried with the following but it is not working: sed -e "s|JAVA_OPTS= |JAVA_OPTS=<some_value>"

View 2 Replies View Related

Networking :: Defining Two Gateway With Different IPs

Aug 2, 2009

I have a server with 192.1.9.10 ip address and I want to define two gateways with ip: 192.1.9.4 and 192.1.9.254 on it but I don't know how I can do it. I don't have professional information in linux.

View 1 Replies View Related

Ubuntu :: Changing Keyboard Layout Or Defining New Hotkeys?

Dec 21, 2010

I use Persian language on my system and I really need two things:1. To define a custom layout for my keyboard. I am used to a layout that is not available in Ubuntu. Can I do that? (For example I need the system to enter a ****پ character instead of when I hit the backslash key)2. Defining a custom hotkey. I used a hotkey program in windows so I could enter no-space breaks with shift+space. Can I define that in Ubuntu

View 3 Replies View Related

Programming :: C++: Defining A New Class - Periodic B.c?

Apr 9, 2010

I am trying to make a periodic boundary condition type function, using an existing class given to me in lecture notes, but am having some trouble! Effectively, I am trying to make an array such that, for a point in any row of a 2D matrix ("Matrix(i,j)"), the command "next_i[i]" will return "(i+1)%L", where L is the number of data points in the row. This will enable me to select a point to the right of any point in the matrix: "Matrix(next[i],j)"

[Code]....

View 1 Replies View Related

General :: Defining An SSH Source Port?

Feb 15, 2010

When one connects to an SSH server running on a non-standard port ( i.e. not port 22) it is straightforward to alter the command syntax so you can connect to this port. Is it possible to define the source port from the local machine ? For example, can you define the source port on your local machine to be 12345 as opposed to another port chosen by your system?

View 2 Replies View Related

Programming :: Defining Functions - What Is The Difference?

Aug 12, 2010

But what is the difference between this...

Code:
my_fucnction () {
echo "Hello World"
}
Code:
function my_fucnction {

[Code]...

View 10 Replies View Related

Ubuntu Multimedia :: Defining Primary Display ( 3 Monitor Setup)?

Jul 6, 2011

I have a Radeon HD 5830, running 3 monitors on 10.10 64bit with the 10.6 video driver. The three monitors ( from left to right ) :

DFP1 : 1152x2048
DFP2 : 1920x1200
CRT1 : 1360x768

The problem I'm having is getting the middle monitor to be the primary one.

Running
xrandr --output DFP2 --primary

puts the panel on the middle screen but my docky and icons stay on the left screen. Flash videos also open up on the portrait left monitor which looks awful. Ideally I would like the icons on DFP1, docky on P2 and flash videos to open on P2. But I would definitely settle for everyone to be on the middle screen and drag it around as I please.

[Code]...

View 3 Replies View Related

Ubuntu :: Defining Root File To Install 10.04 On A Partitioned Disc?

Nov 19, 2010

I am trying to install Ubuntu 10.04 into an existing partition. The other partition contains some backups.

When I get to step 5, the system freezes on the message that no root file system is defined. Correct this from the partitioning menu.

I have tried the options, but except for allowing the installation to take over the whole disc, erasing my backups, there does not seem to be an alternative way forward.

The following partitions are shown:
sda1 (fat16) 33,7 MB
sda6 (fat16) 26,2 GB
sda5 (ntfs) 53,8 GB

My backups are on sda5 and I am trying to install Ubuntu on sda6.

View 1 Replies View Related

General :: Defining Private Samba Shares?

Oct 24, 2010

I'm trying to modify my Linux server's Samba config so that each user gets their own private folder, in a similar way to having a private 'home' folder. Is it possible to create a samba share that maps to different places, depending on username? E.g if 'bob' connects they see the contents of /documents/bob and if 'fred' connects they see the contents of /documents/fred, and so on?

(I know this is what the [homes] share does, but I want another specifically for each user's private documents that won't get mixed with all the Linux user cruft such as dotfiles and things)

View 1 Replies View Related

Software :: Defining New Dhcpd Options Failed?

Jun 30, 2011

i have to define new dhcpd options to provide data for a pxe winpe boot. So these options will be under a bootstrap session. This doesn't work.

option ff code 145 = text;
option ff "test";
option sitepxe code 138 = text;
option sitepxe "test";
option clienthostname code 139 = text;
option clientMAC code 140 = text;
option bcdmenu code 252 = text;

In a wireshark capture i can't see the new options in the DHCPACK packet. ISC-DHCP is always restarted when the conf file is updated.

View 5 Replies View Related

Software :: Defining Video* With 2 Webcams In Udev?

Apr 13, 2011

I have two identical webcams and I want to assign video0 and video1 to a particular one. I understand I can do this using udev but a bit stuck as being both the same they have the same attributes.

[Code]...

View 2 Replies View Related

Red Hat / Fedora :: Defining Quota For A User At Folder Level?

Jan 7, 2011

We are using Red Hat Enterprise AS 3.0. There are 100+ users connected to a single server. As the Inbox size of Mail Client (Thunderbird) for each user grows there are space constraint on the server. So I want to define a quota on mail folder for each user (say around 500 MB to 1 GB). How can I do this.

View 3 Replies View Related

General :: Defining A Root On A Just Installed Netbook Edition

Aug 16, 2010

I just installed an ubuntu netbook edition on my notebook. In the installation process I defined a user with a password. I can use that password to access many system tools, like the synaptic package manager, adding users and so on..

However, when I wanted to do some staff in a terminal as a superuser (using the su command), and I enter my password (There is only a single user and a single password so far) I get authentification failure.

I went to System-->Administration-->uers and groups . I changed the my account type to an "Administrator" (for that I used again my password). hoping that I can use the su command but still it did not work..

I feel that the superuser needs to be set or defined. Since I have not done that then whatever pass word I enter after the command su I will always get "authentification failure"

How can I define the superuser and tell the system that I am the superuser of this computer?

View 14 Replies View Related

OpenSUSE :: Defining Default Applications Via Command Line/terminal?

Apr 7, 2011

I recently upgraded from 11.3 to 11.4 succesfully. I had to reinstall several applications and, some of them, can't be configured as default from the control panel (e.g. Opera as default browser, VLC as default media player). The problem is that droplists at the prefered applications don't show any other than the default ones, Firefox and TotemIs there a way I can change these settings via command line or a way to fix what applications are shown at the control panel?

View 8 Replies View Related

Server :: Defining Persistent Device Naming On A Debian Lenny?

Nov 25, 2010

I have a problem defining persistent device naming on a Debian Lenny server.I have:RAID1 controller on the server machine with two SCSI disks.external storage with RAID5. I have / mount on the first partition on the server SCSI disk and /storage mount on the external storage. I'm experiencing a problem: The system recognizes the system disk (RAID 1), as sda or sdb randomly.I want: To control the recognition, and tell the system that sda (sda1) will always be the system disk.The motivation: GRUB is configured to work with sda, and when the system disk doesn't, boot process fails, and I end up in the initramfs shell-like interface.

Code:

Booting the kernel
.
.
.
mount:mounting /dev on /root/dev failed: No such file or directory
mount:mounting /sys on /root/sys failed: No such file or directory

[code]....

View 7 Replies View Related

Ubuntu :: Cannot Compile - Warning: Incompatible Implicit Declaration Of Built-in Function "printf"

Dec 25, 2010

Cannot compile? warning: incompatible implicit declaration of built-in function "printf" I have build-essential.

View 5 Replies View Related







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