Programming :: Simple Bash Script Not Returning Correct Value?
Sep 14, 2010
I have a very simple bash script:echo -n Create home directory?:
read HOMEDIR
if [ $homedir="y" ] || [ $homedir="yes" ]; then
homeval=" --makehomedir"
[code]...
View 6 Replies
ADVERTISEMENT
Feb 12, 2010
I have having some trouble working with wide characters, which is,
Sample code:
TCHAR fname[512];
_tcslcpy(fname, L"/root/Desktop/all/TheGrandTunnels.fgc", 512);
[code]...
View 4 Replies
View Related
Nov 7, 2010
I have been looking at: ut a lot of it is to do with files and numerical comparisonswhat would be the bash equivalent of:if (http isin $2) { do something }
View 2 Replies
View Related
Nov 4, 2009
I am trying to create a function that takes a pair of a high and a low limit, and returns an arbitrary number between them. Below is my attempt to create a function that accomplishes this by checking to see if they are equal, and if not, subtracts a very small number from the high limit and returns the result.
View 2 Replies
View Related
Apr 11, 2011
I have a directory that has a bunch of files and directories under it that I need to correct the filenames of. In fact, I plan on running this as a cronjob to keep checking filenames for certain characters. I want directories and filenames with spaces or pluses (+) to have those certain characters replaced with underscores (_). I know that this will involve sed but I'm not sure what else. A simple shell script would handle it.
View 1 Replies
View Related
Jun 14, 2010
I am running a simple script that I copied from slug.ceca.utc.edu/docs/2009-3-26-linux-server-health.pdf and edited with the names and paths of my own servers. I don't know much about scripting (re: nothing) but I wanted to try and be efficient in my new role as a Linux Sys Admin. The script was saved to root's home directory and runs as part of root's crontab once a week. The script runs with no problem, but it doesn't actually seem to run all of the commands contained within. It skips some in the middle and the end and I don't know why. The script itself is this:
Code:
#!/in/bash
uname -a > /tmp/server.txt
[code]...
View 5 Replies
View Related
Jan 31, 2011
I have a folder of 2 many files that the old ls just hangs.
I am trying to write some log files such as;
I don't mind doing one at a time, but I am just playing and even getting the listing I am not getting the date stamp, I have the following;
That does create the file, but all the files look like this;
So basically it's just sticking that ls inside the log file and not actually running the ls, so how can I use the above type to get files just created per year?
View 2 Replies
View Related
Dec 10, 2010
I have been searching for 90 minutes for something that I "think" should be fairly easy. I'm pretty new to Bash Scripting so I could be completely wrong. Then again it may be a weird request to even need something like this. But here it is.I have a script written to convert data from one of our software version to another. The only thing I need to add to it is a "check to make sure the user running the script is in the /tmp directory".
View 7 Replies
View Related
Feb 7, 2011
Im constructing a menu for a program using case. I have all my normal input options mapped out but i want to have a * ) option so that if something else is inputed, it displays "Incorrect input" and then resumes the normal menu function. How do I do this? Ideally, I'd like it to display "Incorrect Input" and then accept more input for the menu.
View 2 Replies
View Related
Apr 25, 2011
If I have files named like this:
abc_one.c
egx_two.c
tsf_two.c
[code]...
View 9 Replies
View Related
Mar 17, 2010
i am dealing with this problemI have a function
function Une {
...
return $some_variable
[code]...
View 6 Replies
View Related
Oct 7, 2010
i'm a college student studying pc programing, and i was given today a special work and i have to program using miranda... which i've never used it >.< can anyone give me a hand to where to download, how to compile, and a simple tutorial for making a simple program or something?
View 3 Replies
View Related
Jun 23, 2010
I am facing the problem of calling cfitsio library from C program in linux. when i am givingthe option "gcc -o CreateLevel1DataFitsFile CreateLevel1DataFitsFile.c -lm -lcfitsio
"i am getting following error
/usr/lib/../lib/gcc/i386-redhat-linux/3.4.4/../../../libcfitsio.a(getcolj.o)(.text+0x7065):/backup/Astrosat/learning/cfits/cfitsio/getcolj.c:3098: more undefined references to `__xtoll' follow
[code]...
View 2 Replies
View Related
Sep 11, 2014
I am developing a script to automate some database setup, but I have an issue I cannot figure out. I prompt for some input with whiptail and select a default if nothing is entered. However, if you do not enter anything, it normally returns 0, but this time it is returning an empty value.
Code: Select all # This one does work!
# Set the source path
TMPPATH=$(whiptail --backtitle "Linux Build Configuration"
--title "Source-Code Path"
--inputbox "Default: $SRCPATH" 0 60
3>&2 2>&1 1>&3)
[Code] ....
So what is wrong with the second code?
View 1 Replies
View Related
Jan 23, 2010
I've got a strange bug that I cannot figure out how to solve. Here is the function.
Code:
int getnexttab(char input[], int index, int length)
{
[code]....
View 14 Replies
View Related
Mar 21, 2011
I have created an object where I pass a string and a long value to it <in Java>, currently I am adding the values to my Object so I can then add it to a list like so:
Code:
List myList;
ImageObject io;
for(i = 0; i < 10; i++)
[code]....
This is what the object currently looks like:
Code:
public final class ImageObject<name, time>
{
public String name = "";
public long time = 0;
[code]....
View 1 Replies
View Related
May 28, 2010
I am getting following assertion in my application:
pthread_mutex_lock.c:275: __pthread_mutex_lock: Assertion `(e) != 35 || (kind != PTHREAD_MUTEX_ERRORCHECK_NP && kind != PTHREAD_MUTEX_RECURSIVE_NP)' failed.
all my mutexes are of type PTHREAD_MUTEX_RECURSIVE and as per all the man pages/tutorials, EDEADLK error is to be returned for mutex of type PTHREAD_MUTEX_ERRORCHECK ONLY.I really should not be hitting this assertion.Would some kinda weird memory corruption be causing this? Or is there something more to it that I am not aware of.I am using linux kernel 2.6.2, glibc 2.5 on PPC.
View 8 Replies
View Related
Sep 29, 2010
we have a multi threaded program on Linux where one thread is waiting on poll() system call with event set to POLLIN, & another thread has closed the same socket fd (which is passed to poll) , but the poll() did not return, is this the expected behavior? From man page of poll we found that the poll should return POLLNVAL if the socket fd is closed, is my understanding correct or is there any bug in the poll()?In Solaris we observed that the poll system call is returning with POLLNVAL if the socket is closed.
View 3 Replies
View Related
Mar 3, 2010
does anyone know how to calculate an average in a simple way with bash? I've got something like this:
Code:
$ cat results.txt | head -10 | tr " " " " | cut -f13
0.23929285124
0.404716908011
0.35113102608
[Code]....
and now I want to calculate the average of the resulting numbers. I know I could write a bash or awk or perl script and use that, but isn't there a more simple, elegant way? There is for example "sum" in the coreutils, but no "avg"..
View 9 Replies
View Related
Oct 26, 2010
I am trying to use the date command in a simple bash script as below:
#!/bin/sh
this_date=`date`
echo "The date is $this_date"
This script seems to work only if a surround the command with the `` characters, which I copied from another script. Can anyone tell me why this is, and how I can insert these characters from my keyboard,which only has normal quote and double-quote characters?
View 5 Replies
View Related
Feb 18, 2010
When I run this command from shell, it runs ok
export REVS=`svn info svn+ssh://svn.myone.ca/var/svn/story/trunk/lib |grep 'Last Changed Rev:'| awk -F: '{print $2}'`
However when I save it into a file called test.sh (of course, I chmod it with +x), I got error "export: 2: bad variable name"
Here is the file:
#!/bin/bash
export REVS=`svn info svn+ssh://svn.myone.ca/var/svn/story/trunk/lib |grep 'Last Changed Rev:'| awk -F: '{print $2}'`
I am using ubuntu.
View 7 Replies
View Related
Feb 20, 2010
Are there any tools that can be used to create a simple GUI for the bash script files i have created, and the GUI should be able to run on both Solaris and Red Hat systems.
View 4 Replies
View Related
Jul 9, 2011
I wrote this script which works but it should run automatically about once per week. I hunted and experimented with KDE Task Scheduler (no dice and no help anywhere) and cron (confusing instructions and cannot edit crontab -e with vim, and cannot enter cron folders/files). I would settle for a desktop shortcut to run the script but found no for that.
Script:
Code:
#!/bin/bash
xterm -hold -e fstrim -v /
Machine:
OS: openSUSE 11.4 x86_64
[code].....
View 13 Replies
View Related
Dec 24, 2010
All of a sudden,i can't execute a simple script as follows:
exit 0
and:
exit
View 18 Replies
View Related
Sep 23, 2010
I have bash script for converting files. I have a problem. If file name is "corrupted" then mv command for that file will not work. For example file with "-" in front of the name.
Is there a way to check if in some folder (subfolder) all the files have correct file names or they don't?
If they are all correct -> OK proceed with execution of the script!
If they are not all correct -> NOT OK stop with execution of the script!
View 4 Replies
View Related
Apr 3, 2011
How to made a simple website in linux using bash scripting.
View 3 Replies
View Related
Apr 11, 2011
I need help as I am not proficient with Linux C++ Programming. There are two parts which I need to do in the coding provided below.
1. Produce the program so it can output the word "Hey there!" and wait two minute and print the word "See you later!".
2. Produce the program that will output the text "Cool" every 20 seconds by setting a periodic task.
Quote:
#include <linux/kernel.h>
#include <linux/module.h>
MODULE_LICENSE("GPL");
int init_module(void)
{
printk("Hey there!
[Code]...
View 3 Replies
View Related
Feb 12, 2011
im trying to build a simple program for my C programming class, this is the source code
#include <stdio.h>
int main()
{
int length, width, length, height, area, perimeter;
perimeter = width + length + height;
area = width * length + heigth;
[Code]...
i dont see any error (you might)but every time i run it it runs but after it asks me to input for the width i do it but it doesn't take me to the length, it just stays blank until i input another value in the same place for the width, it asks me for 4 inputs in total i don;t know why, and after i run it different times it gives me different values for the perimeter and are. how can I fix this?
View 5 Replies
View Related
Aug 2, 2009
Ive been using linux for a while but I am just getting into shell scripting, im currently trying to get a simple script for finding and copying files powered by the command:
Code:
This works fine from the command line but when put in a script such as:
Code:
Code:
with the keyboard inputs for $fc1 and $fc2 being *.doc and ~/test respectivly. The only problem i can see is the xargs -ivar "var" part possibly needing $var to be defined?
View 2 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