Programming :: Bash --login BUG ( In RC Scripts )?

Aug 25, 2010

The --login flag should be load also the ~/.bash_profile (see man on bash).BUT the problem is that when using this bash �login -c command on RC scripts then it is not load the ~/.bash_profileAnyone know why only in RC scripts it's not behave good?

View 4 Replies


ADVERTISEMENT

Programming :: BASH Shell Differences: Login Or Interactive

Feb 18, 2011

Intuitively I think that the Login Shell and the Interactive Shell are the same applications but have access to different environmental variables.It this true? Why is there more than one type of shell anyways? You can change users with the interactive shell, why not log on with it to?

View 10 Replies View Related

Programming :: Bash: Printing The Line Number In Bash Script?

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

Programming :: Bash Ctrl+c Tarp And Bash Read With Timeout?

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

Programming :: Reading A Bash Variable In Bash Scripting ?

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

Programming :: Run Multiple Bash And Php Scripts From A Bash Script?

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

Programming :: Bash: Get Filename And Extension Using Bash?

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

Programming :: Bash Programming - Rename Files In A Loop?

Mar 31, 2011

I need to rename the resulted searched files from a loopI have the following code:

find . -name DOC* | while read i
do
find $i -type f -name '*.txt'
done

basically, I am searching for all txt files inside any folder starting with DOC name.this code is working fine with me.I need to rename those .txt files to .txtOLDOS: Ubuntu 10.4Bash shell

View 10 Replies View Related

Programming :: Write A Bash Script That Sources Another Bash Script?

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

General :: Root Login Directly Into -bash-3.2#?

Mar 22, 2010

i am using fedora 10 while i login as a normal user its working fine username@hostname while i login as a root user it goes directly into -bash-3.2# if i check pwd it shows /root till now i am not facing any problem as i am using as a normal user but how can i change -bash-3.2# to root@hostname which file and where to edit

View 9 Replies View Related

Debian :: Login Via SSH - Bash Autocomplete Stopped Working

Feb 3, 2011

For some reason my bash autocomplete stopped working. I get the error when I try to cd into a directory, pressing <tab> for autocomplete:
cd A-sh: <( compgen -d -- 'A' ): No such file or directory
Autocomplete works for the root user and for the other user on the machine, just not logged in as this user. The .bashrc file looks fine to me, and I didn't make any changes to it to even cause the bash autocomplete to stop working (as far as I know).

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
What else could cause autcomplete to stop working? I log in via ssh, btw.

View 11 Replies View Related

Fedora :: Terminal Now Opens As -bash-4.0$ And Will Not Let Login As Any User?

Dec 3, 2009

For some reason my terminal now opens as -bash-4.0$ and will not let me login as any user.Is there anyway to fix this? It's very annoying and I've never came across it before.

View 4 Replies View Related

General :: Bash Script Output To Console Without Login?

Dec 30, 2010

i'm looking for a way to output a bash script to the console before login.It should be executed after boot in rc.d scripts with the output on the console0. It is for a asterisk box.This is the script. It use the watch command to output the active calls on the box in realtime.Code:watch "asterisk -vvvvvrx 'show channels verbose'"Btw,

View 6 Replies View Related

General :: Online Shell / Bash Login Using SSH Port

Sep 18, 2010

Any one tell me online bash login using putty [ssh port] for practicing a linux.

View 6 Replies View Related

Ubuntu :: Scripts In Bash And Perl - Users Hasn't Been Able To Login

Jul 29, 2011

I've been asked to do certain jobs doing scripts in bash and perl. So this time they asked me to check which users hasn't been able to loggin. DONE with Code: lasb Now they asked me to show how many times all the users have input certain Bash Commands like

Code: Ls Cd pwd I was wondering if there was a command of something that could show me how many times those commands has been used, I already know I can see all input with Code: history Sorry I'm really new to this, been working with this for a couple of weeks, and its really interesting.

View 3 Replies View Related

General :: Auto Start Bash Script After Login To Desktop?

Mar 26, 2010

I am using Fedora and trying to auto run a script soon after the unit boots to desktop. I found many suggestions and finally decided to use the Sessions->Startup Programs option (under System->Preferences->Personal->Sessions menu). I added my script in the Startup Programs with the command 'sh myscript.sh'. Now I have two questions here:1. When I use the command 'gnome-terminal -e myscript.sh', I get 'There was an error creating the child process for this terminal' message after logging into the desktop. Can any one tell if I am missing something here?2. Even if I use sh instead of gnome-terminal, I still want to see the script executing. In other words, my script has certain echo statements indicating the flow of the script. But I don't see any shell opening up with these echo statements showing up, after the unit boots to desktop. But the script was still executed with no problem

View 1 Replies View Related

General :: Can't Connect To Display After Switching From Bash To Tcsh After Login

Aug 11, 2010

Can't seem to use tcsh as my login shell under CentOS 5 as I used to (if I specify /bin/tcsh as my start-up shell, the windowing system doesn't come up), so am logging in under bash then switching to tcsh on top of that, but it won't allow display access from tcsh for my programs. Gives the "cannot connect to display" error that usually xhost + is the solution for, but xhost doesn't help in this case (won't even run under tcsh, says unable to open display "0.0"). $DISPLAY is set in .cshrc. Must be something simple, but can't seem to find a direction to head?

View 2 Replies View Related

CentOS 5 :: Bash Script Command For Auto Login On Several Hosts

Nov 2, 2010

I am trying to make a bash-script for auto-logins on several hosts, seems there is a problem with the quotes and I can't figure it out. I've experimented with singles and doubles but no luck yet. Below are two variants with respective outputs. In both cases the output of echo works fine if I copy and paste it to a prompt, but when executed from the script it falls down.

* Only one case-clause for testing...
* Not possible to use passwordless key-login

#!/bin/bash
PASSWORD="my_password"
case "$1" in
"example1" ) HOST="example-host-1"
echo $HOST;;
esac
if [ $HOST ]
then
COMMAND="expect -c 'spawn ssh $HOST ; expect assword ; send $PASSWORD
; interact'"
echo $COMMAND
exec $COMMAND
else
echo "No host argument"
fi

View 7 Replies View Related

Programming :: Bash Scripting To Programming?

Jul 13, 2011

i'm in the process of learing C++. currently i'm creating shell scripts to get things done. i'm just curious how, as a programmer using C++ you would get a similar job done.as an example i have a script that takes the contents of files, pipes it to some sed and awk commands, which is piped to create a new file. that file is then imported into a mysql database.if you were going to do this in C++, would you call the sed/awk programs to modify the file, or can it be done within the program itself? i'm probably jumping the gun here because i've just started learing about pointers so this is above my ability

View 12 Replies View Related

Programming :: Sed A Variable In Bash?

Mar 25, 2011

I have beat this enough and don't get what should have been a very simple thing to do. I build a variable;

Code:
CLIST=java,lua,python,php,perl,ruby,tcl
CLIST will be used by another bash script but I need to replace the commas with a space. I

[code]...

View 2 Replies View Related

Programming :: Bash Script HELP - Hex To Dec ?

Dec 4, 2010

Creating script that converts hex to dec. But without using bc calculator or other methods that could convert it in one line. I need to make something like this script that converts dec to hex.

View 1 Replies View Related

Programming :: Can Use Bash Within An Awk Script

Apr 14, 2011

I have a basic awk script that can read a file named 'server_info' and output to the screen which fax lines are not working. Now I want to make the script execute commands instead of printing to the screen but I am having trouble... This is better explained by my code below:

test.sh Code: #!/usr/bin/awk -f
#
#The name of this script is test.sh

[code]....

View 1 Replies View Related

Programming :: Bash Command From PHP?

Jul 14, 2011

Distro: Centos 5, PHP 5I have done a bit research on running bash commands from php and there was little success. This is my relevant php script

<?php
echo exec('pwd');
?>

[code]...

View 16 Replies View Related

Programming :: Bash Function Using If / Then And Else

May 2, 2011

I am trying to build a function inside a script.

Code:
#!/bin/sh
#System commands and other configurable.
IPT=/sbin/iptables
IP6T=/sbin/ip6tables
IPST=/usr/sbin/ipset
MODP=/sbin/modprobe
GET=/usr/bin/wget
INT_NET=192.168.1.0/24 .....

I can find lots of tutorials in how to use if, then, else. However, how do I define a variable inside the function?
SEE>>
Code:
for c in $ISO
Also, am I using the 'test' command correctly( -/+ week as valid test)?

View 7 Replies View Related

Programming :: Bash IF Using IP Subnets?

Feb 14, 2011

I'm somewhere between Novice and I have no idea what I'm doing with bash scripts. I'm writing a script to deploy images using partimage on my company's desktops, and while I have just about everything else figured out I have one issue left.Each of our 4 sites that will be using this disc will have a deployment server due to the fact that our sites have dedicated point to point links that our business traffic is conducted on. I need to be able to determine what site I'm at based onubnet and set a variable based on this determination. What I don't know is how to get the IP address in to an if statement, and properly determine subnet. For example:

192.168.1.0/16 - 192.168.7.0/16 need to use DEPLSERV01
192.168.8.0/16 - 192.168.16.0/16 use DEPLSERV02
192.168.17.0/16 - 192.168.24.0/16 use DEPLSERV03

View 1 Replies View Related

Programming :: Difference Between /bin/bash And /bin/sh?

Dec 27, 2008

I know it's a very silly question but could someone please explain the difference between "/bin/bash" & "/bin/sh" I was under the impression that both are same but following output on my Ubuntu 8.10 is making me raise my eyebrows.

Quote:

parag@station3:~$ ls -l /bin/bash ; ls -l /bin/sh
-rwxr-xr-x 1 root root 725136 2008-05-13 00:18 /bin/bash
lrwxrwxrwx 1 root root 4 2008-12-03 21:42 /bin/sh -> dash
parag@station3:~$

View 11 Replies View Related

Programming :: Run Bash Script On Web?

Apr 9, 2010

i want to run bash script on website.i still have to choose between unix hosting and windows hosting. my web hosting service offer Own Cgi - Bin PHP,ASP,MYSQL,MSSQL, and script schedule(cronejob). This is script

#!/bin/bash
#Store arguments from bash command line
fight=$1
support=$2
msg=rmsg

[Code]....

View 2 Replies View Related

Programming :: Using Eval In Bash?

Nov 23, 2010

Having a problem with an unwanted redirection in in a function call. Although this isn't the function it does illustrate the problem:

Code:
#!/bin/bash
doat () {
ALL="sys1 sys2"
for Sys in $ALL;do
echo "---> $Sys <---";
echo $(eval echo $1);

[Code]...

figure out how to get the variable into the command without outputting to the file in the eval statement? So that ssh line that gets executed would look like the following to each iteration of the for loop:

Code:
ssh root@$Sys rpm -qa|sort > /trans/${Sys}-rpm-list.txt;
doat works when the incoming argument doesn't have any redirection in the command.

View 3 Replies View Related

Programming :: Using Gambas With Bash?

Jun 8, 2010

Is it possible to use Gambas as a GUI to read text string variables that are input by a user, and use the variables in a bash command?

I know how to do this simply with bash, but I want a GUI that little kids can easily use.

View 2 Replies View Related

Programming :: Variable Substitution In BASH?

Feb 17, 2011

Just a simple BASH for loop to read the file path from a text file (clean.txt) echo the variable for debug purposes, and scp it to a server I have using port 50 for SSH.

I've already formatted the entries in clean.txt to handle spaces correctly, using sed replacement.

Example from the clean.txt file:

Code:
/MP3/NAS000000001/Barenaked Ladies/Barenaked Ladies - Barenaked For The Holidays/20 Auld Lang Syne.mp3
/MP3/NAS000000001/Barenaked Ladies/Barenaked Ladies - Barenaked For The Holidays/14 Deck the Stills.mp3

[Code]....

View 5 Replies View Related







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