shell 에서 PATH, LD_LIBRARY_PATH 설정하는 Shell 호출시 미작동

poplike의 이미지

안녕하세요

Shell Script 로 Install Package 를 만들고 있습니다.

모든 과정이 끝난 후에

PATH, alias, LD_LIBRARY_PATH 등등

시스템 환경 변수들을 설정해 놓는 Shell 이 따로 있는데

Install Shell 에서 Install 이 성공적으로 끝나면 시스템 환경 설정 Shell 을 호출 하도록 되어 있습니다.

절대 경로로 호출을 하도록 되어 있구요.

sh -x 로 결과를 봐도 분명 호출한걸로 보입니다.

하지만 작동을 하지 않네요.

터미널 콘솔에서 직접 환경 설정 shell 을 호출해보면 정상적으로 PATH도 먹고 LD_LIBRARY_PATH 도 분명 잘 되는데

Shell 에서 Shell 을 호출하면 왜 안될까요?

install.sh

/home/setpath.sh

setpath.sh

export PATH=/home:등등등
export LD_LIBRARY_PATH=등등등
alias vi=vim

위와 같은 형식으로 호출을 합니다.

환경설정 쉘을 /etc/profile.d/에 소프트 링크로 걸어 놓으면

터미널 재접속시 잘 작동합니다.

-------------------------------------

2차 질문

source 를 쉘안에서 실행 하기 때문에 해당 쉘에서만 변수가 세팅되는거 같군요

환경 변수를 실제 사용중인 터미널까지 적용을 하려면

어떻게 실행하여야 할까요?

eseo의 이미지

쉘을 호출할 때, source 를 사용해 보세요

source /home/setpath.sh

---
배려하는 마음을 갖자.

poplike의 이미지

source 로 불러와도 안되더라구요 ㅠㅠ

eseo의 이미지

정확한 예시가 없어 잘은 모르겠지만, 역시 source 로 해결하면 될것처럼 보이는데요? :)

Quote:

2차 질문

source 를 쉘안에서 실행 하기 때문에 해당 쉘에서만 변수가 세팅되는거 같군요

환경 변수를 실제 사용중인 터미널까지 적용을 하려면

어떻게 실행하여야 할까요?

install.sh 자체도 source 로 호출해야 현재 쉘 환경에서 실행이 됩니다.

source install.sh

보다 자세한 사항은 man source 로 확인해 보세요.

---
배려하는 마음을 갖자.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.