WebFaction
Community site: login faq

The System() API call takes a session_id and if you have previously created an app in that session, uses the working directory of the app you created.

Is there any other way to change the working dir for System() commands?

asked 14 Feb '11, 15:00

sxalexander
8125
accept rate: 0%


Just pass multiple commands to a single system() call, like this:

cmd = """\
cd /home/you/some/directory
whatever_commands
"""

# you can also do this:
# cmd = 'cd /home/you/some/directory; whatever_commands'

server.system(session_id, cmd)

Hope that helps!

permanent link

answered 14 Feb '11, 15:55

seanf
12.2k42136
accept rate: 37%

Thanks! That does solve the issue with system(), is there a way to do something similar with replace_in_file()?

(14 Feb '11, 18:16) sxalexander

With replace_in_file() you can put the full path to the file you need to edit not change directories, as such. After in the same cmd = """ field you should be able to call replace_in_file() after you've changed to the directory you want.

(14 Feb '11, 18:43) klynton
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×113
×76
×2

question asked: 14 Feb '11, 15:00

question was seen: 3,603 times

last updated: 14 Feb '11, 18:43

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM