LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 02-23-2005, 07:36 AM   #1
darkRoom
Member
 
Registered: Mar 2004
Location: Valencia, espaņa
Distribution: Slack, Gentoo, Custom
Posts: 162

Rep: Reputation: 30
shell script + change shell && continue


Hi
Is it possible to have a script which will execute this:
Quote:
exec /bin/bash --login
and then continue the rest of this script in this new shell ? I read that exec never retruns success so im thinking no, but hey if theres a possibility . . .

thanks
 
Old 02-23-2005, 08:01 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,314

Rep: Reputation: 175Reputation: 175
dont think so.
 
Old 02-23-2005, 08:27 AM   #3
hiteshmaisheri
Member
 
Registered: Nov 2003
Location: Kerala, India
Distribution: Red Hat, Knoppix, Mandrake, FreeBSD
Posts: 231

Rep: Reputation: 30
hii,
if you rean the man page exec, it clearly states that it replaces the current shell
your can read the man page for the exec command it is as given below :
If command is specified, it replaces the shell. No new process
is created. The arguments become the arguments to command. If
the -l option is supplied, the shell places a dash at the begin-
ning of the zeroth arg passed to command. This is what login(1)
does. The -c option causes command to be executed with an empty
environment. If -a is supplied, the shell passes name as the
zeroth argument to the executed command. If command cannot be
executed for some reason, a non-interactive shell exits, unless
the shell option execfail is enabled, in which case it returns
failure. An interactive shell returns failure if the file can-
not be executed. If command is not specified, any redirections
take effect in the current shell, and the return status is 0.
If there is a redirection error, the return status is 1.
so it is no possible using exec command ...
you can write a c program fork a process and exec it using the scripts you want is the possiblity i seee...

Hitesh
 
Old 02-23-2005, 08:48 AM   #4
darkRoom
Member
 
Registered: Mar 2004
Location: Valencia, espaņa
Distribution: Slack, Gentoo, Custom
Posts: 162

Original Poster
Rep: Reputation: 30
ok thanks, that was what i was thinking,
 
Old 02-23-2005, 10:05 AM   #5
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

Rep: Reputation: 136Reputation: 136
Why don't you set your first line of script with :
#!/bin/bash --login
 
Old 02-23-2005, 10:27 AM   #6
darkRoom
Member
 
Registered: Mar 2004
Location: Valencia, espaņa
Distribution: Slack, Gentoo, Custom
Posts: 162

Original Poster
Rep: Reputation: 30
Thats a good point but i think the way to go now is write a c program to hold what im doing together. Im just learning how shell scripts work and i have a task which chains together a number of scripts, i guess im finding out what can and can't be done with scripts

thanks
 
Old 02-25-2005, 03:50 AM   #7
hiteshmaisheri
Member
 
Registered: Nov 2003
Location: Kerala, India
Distribution: Red Hat, Knoppix, Mandrake, FreeBSD
Posts: 231

Rep: Reputation: 30
All the best .. do post as many questions as you can.. we will be happy to learn from your experiences and share each others knowledge and experiences...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Req]: How to config WebSvr & DNS Svr from console by Bash shell script CiF Linux - Networking 2 03-22-2005 01:31 AM
Looking for addusesr&passwd shell script szklanka Programming 1 02-22-2005 09:37 PM
shell scripts & change dir pit1516 Linux - Newbie 6 06-22-2004 11:42 AM
Shell Script with ssh & scp ErikJohnson Linux - Software 3 03-11-2004 05:53 PM
Shell Script with ssh & scp ErikJohnson Linux - Networking 1 03-11-2004 05:14 PM


All times are GMT -5. The time now is 11:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration