LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 08-04-2016, 03:56 PM   #1
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Rep: Reputation: 169Reputation: 169
Change directory using script


This changes dir when invoked from a console but not when it is in a script ?

Code:
cd /home/andy/.wine/drive_c/masm32/examples
Why is not working ?
 
Old 08-04-2016, 04:05 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,694

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
When you run a script it starts a new process and that environment only exist within that process. The cd commands works within the process but when it exists your back.
 
1 members found this post helpful.
Old 08-04-2016, 04:23 PM   #3
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
O.K.

So my only option is to manually change directories ?
 
Old 08-04-2016, 04:31 PM   #4
zk1234
4MLinux Maintainer
 
Registered: Oct 2010
Location: Poland
Distribution: 4MLinux, Slackware
Posts: 1,254

Rep: Reputation: 220Reputation: 220Reputation: 220
Quote:
Originally Posted by michaelk View Post
When you run a script it starts a new process and that environment only exist within that process. The cd commands works within the process but when it exists your back.
..so if you intend to run something more (child process) using /home/andy/.wine/drive_c/masm32/examples as a working directory, you must start it within the same script:
Code:
cd /home/andy/.wine/drive_c/masm32/examples
exec your_program_to_run
.
 
Old 08-04-2016, 04:41 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,694

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
You can create an alias or a function.

What are you trying to accomplish?
 
Old 08-04-2016, 05:34 PM   #6
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
I use an assembly editor that is installed in drive_c.

/home/andy/.wine/drive_c/masm32/qeditor.exe

I would like a script to start that editor.

I tried this, but it does not work.

cd /home/andy/.wine/drive_c/masm32/examples
/home/andy/.wine/drive_c/masm32/qeditor.exe

I have a sample program in Dropbox but can not figure how to get a link so someone can download it.

Last edited by Fixit7; 08-04-2016 at 05:42 PM.
 
Old 08-04-2016, 06:00 PM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,694

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
Should not be cd problem. Try:

cd /home/andy/.wine/drive_c/masm32/examples
wine /home/andy/.wine/drive_c/masm32/qeditor.exe
 
Old 08-04-2016, 06:19 PM   #8
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Thanks, it works perfectly.
 
Old 08-04-2016, 06:40 PM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,694

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
Your welcome...
 
  


Reply



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
Cannot change directory/folder in SCRIPT GONMAN1 Linux - Newbie 3 09-10-2015 01:39 AM
How to change directory in a shell script? jdupre Linux - Newbie 13 06-25-2015 05:03 AM
change a directory using script viveksnv Programming 5 02-20-2008 06:00 PM
Script to change directory gudum35 Linux - General 5 05-31-2006 03:43 PM
script to change directory trout21 Linux - Newbie 9 02-17-2004 12:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 11:44 AM.

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
Open Source Consulting | Domain Registration