LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-20-2019, 09:12 AM   #16
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,320

Rep: Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635

ok, so

simple script

Code:
#!/bin/bash
echo $PATH > ~/foo.log
chmod it


I alt+F2

Code:
~/test.sh
and gedit pops up and shows me my script,

so, next try

Code:
bash -c "~/test.sh"
I check the log and have a "normal" path
 
Old 09-20-2019, 09:23 AM   #17
ddenial
Member
 
Registered: Dec 2016
Distribution: CentOS, Fedora, Ubuntu
Posts: 193

Original Poster
Rep: Reputation: 35
Quote:
Originally Posted by Firerat View Post
ok, so

simple script

Code:
#!/bin/bash
echo $PATH > ~/foo.log
chmod it


I alt+F2

Code:
~/test.sh
and gedit pops up and shows me my script,

so, next try

Code:
bash -c "~/test.sh"
I check the log and have a "normal" path
Don't know why? mine is not working.

Code:
# cat /usr/local/bin/test.sh 
#!/bin/bash
echo $PATH >> ~/foo.log

# ./test.sh
# cat ~/foo.log 
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Did the same from Alt-F2
"/usr/local/bin/test.sh" and "bash -c /usr/local/bin/test.sh"

no result
Code:
# cat ~/foo.log 
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
 
Old 09-20-2019, 09:31 AM   #18
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,320

Rep: Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635
I did

bash -c "~/test.sh"
 
Old 09-21-2019, 10:49 AM   #19
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 13,070

Rep: Reputation: 4132Reputation: 4132Reputation: 4132Reputation: 4132Reputation: 4132Reputation: 4132Reputation: 4132Reputation: 4132Reputation: 4132Reputation: 4132Reputation: 4132
~/test.sh and /usr/local/bin/test.sh are two different files in two different directories (although they can be identical).
also redirecting by > and/or >> is not the same, you need to check which one is really used.
 
  


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
ALT+B, ALT+F key combinations in xterm don't work nIMBVS cAos 4 12-15-2011 01:52 AM
cheops-agent wont run by pressing alt+f2 z99 Linux - Newbie 1 07-20-2010 01:00 AM
[SOLVED] Nautilus Shortcuts (Alt-Left, Alt-Right) don't work bgalakazam Linux - Software 2 03-04-2010 01:19 AM
FreeBSD: Difference between Alt Gr and Alt Sharph *BSD 0 10-02-2004 03:45 AM
Alt-Tab and Alt-F4 in Fluxbox? tavilach Linux - Software 2 07-17-2004 04:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:55 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration