- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Using 2 kind of shell only in 1 script
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
тАО12-13-2005 10:49 AM
тАО12-13-2005 10:49 AM
can i use two shells in 1 script, i mean, like next:
#!/usr/bin/ksh
cd /home/files/
aa=`ls -l | grep earn | awk '{ print $NF }'`
#!/usr/bin/csh
echo $aa
this is because with csh i have a message error when i use awk command:
aa1=`ls -l | grep earn | awk '{ print $NF }'`: Ambiguous.
My question is:
can i use two shells at same script:
#!/usr/bin/ksh
cd /home/files/
aa=`ls -l | grep earn | awk '{ print $NF }'`
#!/usr/bin/csh
echo $aa
....
...
..
..
....
when i change kind of shell, can i continue executing command with another sintaxis depending the shell? this is in first part i want obtain a variable with awk command with ksh and then that variable i need use it with others sintaxis with other shell named csh ..can i do it? will i have some problem if i use it in this form?
Thanks, Manuales.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-13-2005 10:59 AM
тАО12-13-2005 10:59 AM
SolutionIt would be better to stick to one script language. "csh" has become less popular I think, and all the new enhancements are being put onto the Posix-sh, which is "ksh" like in most ways.
Rod Hills
- Tags:
- csh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-13-2005 11:05 AM
тАО12-13-2005 11:05 AM
Re: Using 2 kind of shell only in 1 script
how can i use save a variable in a word invoking a command .. this is:
$(....) or `...`
because when i use csh the output is a message error: "Ambigous" and if i use ksh this run o.k.
do you know how can i save a result executed from a command in a variable?
ksh --> result=$(ls -l | awk '{ print $1 }')
chs --> ├В┬┐? can i use $(..) or `..`?? what do i use??
Thanks, Manuales.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-13-2005 11:45 AM
тАО12-13-2005 11:45 AM
Re: Using 2 kind of shell only in 1 script
Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2005 01:51 AM
тАО12-14-2005 01:51 AM
Re: Using 2 kind of shell only in 1 script
awk can be ran from within any script..
if you wanted to "kick off a subshell"
you would right a second script.. exiting the subshell becomes the problem.
Example:
Program 1:
#!/usr/bin/ksh
cd /home/files/
aa=`ls -l | grep earn | awk '{ print $NF }'`
export aa
Program 2:
#!/usr/bin/csh
echo $aa
The #!/shell command line must be in the first line of the script.
Problem exists if any other variables exist that are required may or may not be passed to the subshell.
If you "launch a shell" from with in the program eliminate the "#!" as this winds up being a Comment on any other line then line #1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2005 02:36 AM
тАО12-14-2005 02:36 AM
Re: Using 2 kind of shell only in 1 script
in csh you have to use setenv to assign variables.
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2005 02:49 AM
тАО12-14-2005 02:49 AM
Re: Using 2 kind of shell only in 1 script
set aa=`ls -l | grep earn | awk '{ print $NF }'`
should not have an error under csh. Note the "set" command is required when setting csh variables.
Rod Hills
- Tags:
- set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2005 03:18 AM
тАО12-14-2005 03:18 AM
Re: Using 2 kind of shell only in 1 script
set aa=`ls -l | grep earn | awk '{print $NF}'
for csh use:
aa=`ls -l | grep earn | awk '{print $NF}'
The question I have, is why are you going to all this trouble to get a list of filenames into a variable?
Doesn't `ls *earn*` return the result your looking for?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2005 03:19 AM
тАО12-14-2005 03:19 AM
Re: Using 2 kind of shell only in 1 script
set aa=`ls -l | grep earn | awk '{print $NF}'
<
for ksh use:
aa=`ls -l | grep earn | awk '{print $NF}'
The question I have, is why are you going to all this trouble to get a list of filenames into a variable?
Doesn't `ls *earn*` return the result your looking for?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2005 05:28 AM
тАО12-14-2005 05:28 AM
Re: Using 2 kind of shell only in 1 script
if [[ ... ]]
├Г┬│r
if [ .. ]
or
if (....)
or
if (( ...))
Thanks !!!