Solved

Execute ksh in current environment without dot

Posted on 2014-04-04
3
225 Views
Last Modified: 2014-04-04
Hi,
I need to find the way to execute scripts from main script in current environment, but not use "." (dot)  before script name
Example

#!/usr/bin/ksh
.  ~/script1
.  ~/script2

Maybe use some flag in ksh, etc...

Thanks in advance
0
Comment
Question by:IKeystone
  • 2
3 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39978350
Why not just

~/script1
~/script2

Where's the problem? Do you have to give back environment variables to the main script? That's the only reason for the dot I could imagine.

Of course you have to "export" variables which must be known by the called scripts.

And finally, what's wrong with the dot? Why don't you want to use it?


wmp
0
 

Author Comment

by:IKeystone
ID: 39978449
It is interactive tool I wrote. Variables going back and forward from script to script but stay inside actual session. I need to encrypt scripts but encryption tool  doesn't like dot. In tcsh it is easier (source instead dot) but I don't want to re-write all.
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 39978465
So why not "export" the variables which must be made available to called scripts?  ksh does this automatically when invoked with the "-a" flag.

To make variables set in a called script available to the calling script there is no other way than using the dot or "source", if you don't want to use an external config file.

"bash" allows using "source" instead of the dot and is widely compatible with ksh. Could  bash be an option?

Another idea: Export a variable called SOURCE in the main script:

export SOURCE="command . "

and use $SOURCE instead of the dot, like:

$SOURCE ~/script1
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Utilizing an array to gracefully append to a list of EmailAddresses
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now