Benefit Of Source Command

Hi,

What are the benefits that we get when we choose to source a file rather than execute it as a shell script?

and then in what way is export opposite to source?

It looks like they are doing the same thing, i.e making environment variables accessible in the local shell


Similar Content



Is There A Way To Have A Script Called Source, That Can Be Run Without The Full Path?

Is there a way to have a script called source, that can be run without the full path?

Ex:
When I run:
export PATH=/home/user:$PATH
source

I get:
Code:
$ source
bash: source: filename argument required
source: usage: source filename [arguments]

However I want it to run my script called source:
Code:
$ cat source 
#!/bin/bash
echo "Hello World"

Is there way to override a shell builtin in the PATH var or some other way?

Bash Script Non-interactive Login Shell

Hi

I'm focusing on getting my head around interactive v non-interactive shells, both non-login and login. Basically what scripts are run and how local and global variables behave.

I'm pretty much there except for 'non-interactive login shells'. I understand that 'non-interactive' shells are started when a script is run. However, if I start my script with #!/bin/bash --login, then a 'non-interactive login' shell will be started.

In my mind I would have expected this to be the same as logging in from scratch, albeit without a user\password prompt. In this case I would have thought that any exported variables from the parent shell would be blown away. This doesn't appear to be the case. The 'non-interactive login' shell appears to inherit the environment of its parent 'interactive' shell.

Can anyone explain the purpose of a 'non-interactive login' shell and how they behave in this regard.

Hope this makes sense.

Cheers

Mike

What Exactly Is PATH

books say that PATH variable contains the locations where the shell searches the commands to execute them.

I created a shell script and saved it in /home/user/Downloads directory and then i ran this script from the /home/user/Downloads directory. It did not execute.

however when i did set the path
export PATH=$PATH:/bin/sh within /home/user/Downloads directory, the shell script executed. Does it not mean that PATH variable is holding the locations of the shell program rather than the commands that are to be executed?

everytime i have to give the location of the shell i.e /bin/sh in the PATH variable no matter from where i am executing my script

Pass Variable Value In Ssh Command

Hello all,
I am trying to execute Code:
ssh $a@$b mkdir abc

in a shell script where, a and b are variables
a=username and b=server.ip
It is giving me an error Quote:
ssh connect to host port 22 connection refused
why am I getting the error?? ssh does not accept variables? Can anyone help.
Thanks in Advance

Executable Not Found From /usr/local/bin

Hi,

I installed ghostscript via yum package manager. Later I wanted a newer version of ghostscript and compiled it from source. "make install" placed the gs executable file under /usr/local/bin/gs. This works if I run the command with absolute path, but if try to run gs, the shell will output

"-bash: /usr/bin/gs: No such file or directory"

if I echo the path variable it will display

/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin

If i run whereis it will give me the correct path
gs: /usr/local/bin/gs

How do I make it work so that typing "gs" will run the executable file from the /usr/local/bin/gs?

(I am using Centos 6)

Thanks.

Linux From Windows- Bash ,shell

Hello am a newbie to linux,
I tried to install cygwin for windows,all i need is i need to write a shell program for a batch file i already have, I am not able to do this.
My batch file content looks like

SET JAVA_HOME=..\jdk
SET CLASSPATH="%CLASSPATH%;../lib/A.jar;../lib/slf4j-api-1.6.1.jar;../lib/slf4j-simple-1.6.1.jar"

%JAVA_HOME%\bin\java.exe com.A ../conf/C.properties

PAUSE

this works perfectly, I try to write a shell program which is failing when i check it through cygwin. i am not able to set the export to java_home.
The pblm i face is say my current directory where my shell program is 'Z'
then i want to get back to 'y' where X has two sub folders y and z

X
-Y (is jdk )
-Z (where shell pgm resides)

cd ../ or any combination of cd doesnot work in my shell script.

Please help me. Any help is greatly appreciated

Source Code

hi,
i need source code for clustering and source prefix aggregation in wireless sensor network using tcl in ns2.please help me.

.o: File Not Recognized: File Format Not Recognized When Compiling

Hello,

I am working on a board (sbc6000x with at91sam9261 micro, linux 2.6.24 to be precise) and having some fun making script i wanted to make real application.
The board is coming with a cross compilation toolchain. When trying to make a simple "hello world" executable to print on the terminal there is no problem.
I open my terminal, give the path of the compiler, cd into the folder where my .c file is and then i type :
Code:
arm-linux-gcc -o hello hello.c

Which create my executable "hello" and this one is working. But like i said, this program only played with the terminal.

The board is starting with a script calling another executable which use the lcd display, i have the source of this executable. My idea was to look at what was in the source of this application (lots of folders and files) in order to understand how it was working. I wanted to test the toolchain on the source (with the makefile) to see if i was able to generate an executable from a application with folderS/fileS but when i try to "make" it i have this error.

In my understanding this is an object file but aside from that i don't see why it would not works.

Thank you for your future answers !

SFTP Shell Script

Hi,
I am looking for a simple shell script that allows for sftp to be run from the server to another server (Windows). I would like the script to be passed parameters suchas destination server, Id, password, Directory structure/folder name, file name etc...
Need some help to know how to start with and it would be great if someone help me with any sample sftp shell script

Bash Shell Script Help Please

I want to write a bash shell script to execute a command for one minute then stop that command (ctrl c) pause for 10 seconds then run another command for one minute then stop that command pause for 10 seconds then go back to the begining of the script and loop indefinetly.

First I want to run this command for one minute;

reaver -i mon0 -c 6 -b "mac address" -a -vv

stop previous command and pause for 10 seconds

Then run this command for one minute;

airodump-ng -i mon0

stop previous command and pause for 10 seconds

Then recall reaver command and continue to loop through until reaver spits out result.

I imagine I will need to create a function for each command, an if statement and an ifelse statement and I will need the break and sleep commands. but I am not sure about the syntax, PLEASE HELP THIS NOOB!