- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- How to run Shell script as a source
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2007 12:48 AM
тАО09-28-2007 12:48 AM
How to run Shell script as a source
I want to run a shell script through another shell script but as a source.
Ex - Test1.sh
#!/usr/bin/sh
source Test2.sh
where my Test2.sh will be
#!/usr/bin/sh
export HAI=hai
If give ./Test1.sh
I says
Source not found .
can any one please suggest a solution for this
thanks in advance
Vikram
- Tags:
- source
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2007 12:55 AM
тАО09-28-2007 12:55 AM
Re: How to run Shell script as a source
Sourcing (reading) is done thusly:
#!/usr/bin/sh
. ./Test2.sh
That is, you specify a dot, a whitespace (space, tab) and the name of the file that you want to source (read).
See my other example in your first post using a Perl script, too.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2007 12:56 AM
тАО09-28-2007 12:56 AM
Re: How to run Shell script as a source
Assuming the code is compatible.
. ./scriptname
dot space ./scriptname
If you are in the same directory
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2007 02:18 AM
тАО09-28-2007 02:18 AM
Re: How to run Shell script as a source
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2007 02:51 AM
тАО09-28-2007 02:51 AM
Re: How to run Shell script as a source
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2007 03:22 AM
тАО09-28-2007 03:22 AM
Re: How to run Shell script as a source
but it doesn't hurt and will change the output of file(1) from "ascii text" to "commands text".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2007 03:47 AM
тАО09-28-2007 03:47 AM
Re: How to run Shell script as a source
". file" is the Bourne[-like]-shell syntax.
/usr/bin/sh is a Bourne[-like] shell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2007 04:32 AM
тАО09-28-2007 04:32 AM
Re: How to run Shell script as a source
> Steven: "source file" is the C-shell syntax.
It is also a built-in in the Bash shell ('bash'). There, either the dot syntax or the 'source' builtin can be used to import variables into the current environment.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2007 07:09 PM
тАО09-28-2007 07:09 PM
Re: How to run Shell script as a source
>/usr/bin/sh is a Bourne[-like] shell.
More precisely, it IS the Posix shell.
(The Bourne shell are not the droids you seek. You should only mention ksh and Posix shell. ;-)