Forum     

Go Back   Digit Technology Discussion Forum > Software > Open Source
Register FAQ Calendar Mark Forums Read

Open Source A place where you can talk to like-minded people about the fastest growing software movement today! Discuss anything and everything about Open Source software and Operating Systems.


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 26-08-2007, 06:18 PM   #1 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default A tiny bash issue


Can someone tell me why my little script below (To switch the directory via BASH) does nothing on execution?

Code:
#!/bin/bash
cd /home/qwerty/Programs/C
#abc.sh
Here's my output: (Actually, its NOTHING)

Code:
qwerty@qwerty-workstation:~$ ./abc.sh 
qwerty@qwerty-workstation:~$
I got no clue at all.

And before someone mentions, its chmod +x'ed alright.
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 26-08-2007, 06:28 PM   #2 (permalink)
String Phreak
 
mediator's Avatar
 
Join Date: Mar 2005
Location: In ur Evil Mind!
Posts: 2,457
Default Re: A tiny bash issue

The script is alright and the control return to the original directory after the execution of 'cd' command. That means that the directory is switched as desired and after the execution of the script it returns to the original directory!

To verify it, create some file(s) in '/home/qwerty/Programs/C' and then use some other command with it! e.g
Code:
#!/bin/bash
cd /home/qwerty/Programs/C
ls
This will switch the directory first, show the contents of that directory and then return the control to the original directory!
__________________
Bad Bad server.....No candy for u!
mediator is offline  
Old 26-08-2007, 06:43 PM   #3 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: A tiny bash issue

Thanks mediator, I understand it now, but ..

Can I switch control to another directory permanently? So that my current terminal directory gets changed to that? That was my actual aim.

Edit: I got my silly solution by creating an alias command, but I'd still like to know the way (if possible) to change the current directory via a script
__________________
Harsh J
www.harshj.com

Last edited by QwertyManiac; 26-08-2007 at 06:43 PM. Reason: Automerged Doublepost
QwertyManiac is offline  
Old 26-08-2007, 07:04 PM   #4 (permalink)
I see right through you.
 
Sykora's Avatar
 
Join Date: Sep 2005
Location: Chennai
Posts: 597
Default Re: A tiny bash issue

Try
Code:
$ source abc.sh
Instead of

Code:
$ ./abc.sh
__________________
I didn't make the world, I only try to live in it.
http://lucentbeing.com
-- Sykora --
Sykora is offline  
Old 26-08-2007, 07:14 PM   #5 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: A tiny bash issue

Oh, didn't know about that command before. Problem solved, thanks mediator and Sykora.
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Old 27-08-2007, 07:49 AM   #6 (permalink)
left this forum longback
 
praka123's Avatar
 
Join Date: Sep 2005
Location: -
Posts: 7,536
Default Re: A tiny bash issue

Infact a "." does the job too reg source command:

http://learnlinux.tsf.org.za/courses...g/ch10s02.html
__________________
left this forum long back.Admin Can Delete this Account and posts Permanantly.Thank You
Get GNU/Linux - http://getgnulinux.org
praka123 is offline  
Old 27-08-2007, 11:16 AM   #7 (permalink)
String Phreak
 
mediator's Avatar
 
Join Date: Mar 2005
Location: In ur Evil Mind!
Posts: 2,457
Default Re: A tiny bash issue

^Yup, " . abc.sh " also does the job!
__________________
Bad Bad server.....No candy for u!
mediator is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash colors and icewm themes ra_rav Open Source 6 02-03-2006 06:33 PM
LiMP ver 1.2 - tiny Live CD (Multimedia player tiny Distro) vkkindia Open Source 5 06-12-2005 01:35 AM
Bash script -- Hoary vignesh Open Source 3 13-11-2005 01:37 PM

 
Latest Threads
- by Sujeet
- by soumya
- by clmlbx
- by Charan

Advertisement




All times are GMT +5.5. The time now is 12:58 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2