how to change PATH vars on my iPhone console? - iphone

I installed a terminal i my iPhone and I'm trying to install some utilities on it. To achieve it the only thing I have left is to change the order of the PATH variables on the system but I cannot find the place where they're stored.
When I write $PATH I get
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games
I need to edit the path so the /usr/bin appears before of /usr/local/bin.
I've read sites where they tell me to edit ~/.bashrc, ~/.cshrc, ~/.profile or /etc/paths but none of them exist on my system (in fact in ~ there's just .bash_history and some unimportant directories)
I access to my iPhone (iOS 4.2.1) through ssh from a Leopard MacBook
Any ideas? Thanks

If your .bashrc doesn't exist, you should be able to create it and set it in there:
PATH=$PATH:/extra/path/here:/other/path/here
export PATH
It would appear that you are indeed using bash as your shell since you have a .bash_history, but if you are using a separate shell it could be a separate file.

Related

Swift on Ubuntu 20.04- Need to add a path every time

I am simply trying to install swift on linux
I have downloaded the files from swift.org, extracted .tar files and used export command to include the path after that when I use swift --version it correctly shows the version 5.3.3 but when I close the terminal and try to open the swift command terminal it says command not found.
What is happening here? I need to include the path every time I open the terminal.
The export command just adds the value to path for the current session. When you log out and in again, it will reset.
You need to add this to your shell resource file so that it gets added to the path every time you log in. The file you need to edit will be called .zshrc or .bash_profile or something similar. You should start by opening the command line on your computer and verifying what shell you are running by typing:
echo $SHELL
This will return something like /bin/ksh or /bin/bash or similar. Then do a little internet searching to find out what the resource file is called for that shell. Then edit your resource file to add the Swift path to your $PATH.

Mac OS: How do you fix a PATH to reach an executable file (in this case postgresql & netlify-cli) without messing up other paths?

In the mac terminal:
Does anyone know how to set the path variables for a Mac OS, without messing up other paths?
Current folder structure:
/
/Applications
/[a lot of applications]
/Postgres.app
/Contents
/Versions
/12
/bin
/psql
/Users
/userName
/Applications
/[nothing, except a couple hidden files]
Right now, if I run the command psql, I am getting:
command not found
If I type the full path:
/Applications/Postgres.app/Contents/Versions/12/bin/psql
it works, but typing this every time is not practical.
If I run git that command is available, or code .
Also, I installed netlify-cli globally with npm install -g netlify-cli, but when I run netlify-cli, I get:
command not found
and I don’t know where to find it in my system
… So, something is working correctly with my paths, and something is not. I don’t know how to fix the problem, without messing up other paths.
Does anyone know how I could find out where netlify-cli got installed and fix my paths to netlify-cli and psql without messing up any other paths?
For Mac OS to be able to find the psql executable, it has to be part of the PATH environment variable, you can check the value of that variable on your terminal with this command
echo $PATH
what you should do is add the psql executable to it, like this:
export PATH=/Applications/Postgres.app/Contents/Versions/12/bin/:$PATH
if that solves your problem, you can put that on your .zshrc or .bashrc to make it persistent

Adding perl script to module distribution and making it accessible globally

I'm wondering if there is a tutorial or simple way to add perl scripts which I've written to be accessible to the user globally.
for eg. you apps like Carton, Cpanm, much like how npm has an npm install -g option.
I tried placing my scripts in the bin directory of my perl package but its not working.
The App::* area of cpan contains installable tools and utilities. Looking at a small one, like App::p I saw that its structure looked like it contained a Makefile.PL that used ExtUtils::MakeMaker to define how to build test and install the relatively small perl script.
However, if you're talking about just taking a script you wrote and making it something executable by you, the user, then it's basically the same way all scripting works (apologies if you weren't asking this):
One Unix, Linux and Mac OS X when using a shell like bash:
Any file can be made executable to the user by running chmod u+x filename
An executable file should start with a magic number, for plain text files containing scripts, the shebang is that number. So start your files with (as covered in man perlintro):
#!/usr/bin/perl
use strict;
use warnings;
When specifying an executable file from the command line you can type in the full path, possibly with conveniences from your shell. EG the file is at $HOME/myscripts/runme.pl you can type that at the prompt, the expanded /home/username/myscripts/runme.pl (/Users/username/myscripts/runme.pl on Mac OS X) or ~/myscripts/runme.pl at a bash prompt. Or if runme.pl is in your current working directory: ./runme.pl
If you just type runme.pl sh and bash and many shells will search your PATH variable in order and run the first runme.pl in any of the specified paths.
So if echo $PATH gives you something like: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin and you want the example in point 3 to work with just runme.pl you should
Either move the file into one of those directories (not recommended).
Or add export PATH=$PATH:$HOME/myscripts to the bottom of your ~/.bashrc or ~/.profile file or likewise for your preferred shell. Be sure to open a new login shell session, EG close that terminal window and open a new one.
On Windows, this is an exercise left to the reader. ☺

How to get $HOME in MinGW to not be /c

Any chance that being logged in as Administrator would change how mingw installs? I am running XP. My home directory turns out to be /c, not something in /home`.
Details: Having failed once, I removed MinGW package (mingw-get-inst-20120426) then reinstalled it. During the install of MinGW I chose every option and elected to download latest packages.
I checked my Start->Programs->Mingw->MinGW Shell properties. it is starting C:\MinGW\msys\1.0\msys.bat and the start-in directory is C:\MinGW\msys\1.0\bin. I have determined that / is C:\MinGW\msys\1.0.
But when I run the bat, at the mingw prompt echo $HOME says /c. And there is no directory named /home. echo $USERNAME = Administrator.
Can someone tell me what I did to end up with no $HOME? Do I need to make a *nix user? Or perhaps remove migw and create an XP user and use that user to reinstall mingw?
This was caused by having a Windows environment variable named HOME. It was a leftover from somehting unrelated. Once I deleted it and reinstalled mingw (without deleting the existing one) my home became /home/Administrator. Pity about the capital A, though.
In msys type cd ..
Now you're in a not really existent directory /home .
If you type cd usr
Now you're in a not really existent directory /home/usr .
you will not find home or usr in your c:\msys\1.0 directory.
MSYS is a collection of GNU utilities such as bash, make, gawk and grep to allow building of applications and programs which depend on traditionally UNIX tools to be present.
An example would be building a library that uses the autotools build system. Users will typically run "./configure" then "make" to build it. The configure shell script requires a shell script interpreter which is not present on Windows systems, but provided by MSYS.
A common misunderstanding is MSYS is "UNIX on Windows", MSYS by itself does not contain a compiler or a C library, therefore does not give the ability to magically port UNIX programs over to Windows nor does it provide any UNIX specific functionality like case-sensitive filenames.
My case: I could not find ~/msys/1.0/home/user (user is my user name)
It is resolved - the following is what I discovered.
MinGW/MSYS usually creates a home folder under C:/MinGW/msys/1.0/home/user if you install them as usual (accepting the defaults) and you executes msys.bat successfully. However, it does not create if you happened to have an environment variable called HOME. I think it was a left over from my old project.
First, check your home folder by $pwd -W ($ is a command prompt.)
Remove HOME environment variable.
Reboot
Execute msys.bat again.
Now, check where your home folder by $pwd -W
Note: Don't need to reinstall MinGW/MSYS.
(a debtor)<><

Launch mac eclipse with environment variables set

My company provides an eclipse based development environment which needs some environment variables setting up for the underlying toolchain so multiple versions can be installed concurrently and not take over the system.
I want to provide an icon in finder or the dock which sets these then launches eclipse so customers cannot accidentally launch eclipse without the environment being set. This is what I have tried so far:
Setting environment in Info.plist
for eclipse:
This should be a nice way to do it
but I cannot make it add to the
existing path (like export
PATH=/myapp/bin:$PATH).
bash script wrapping eclipse:
I created a bash script called
eclipse.command to set the
environment then launch eclipse.
This opens a terminal window as well
as the eclipse icon and allows
people to "Keep on dock" for the
bare eclipse. I cannot put
eclipse.command on the dock as it is
not an application.
Applescript wrapping eclipse.command:
An Applescript wrapper around
eclipse.command makes it look like
an app and prevents the terminal
window appearing. Unfortunately I
now get a dock icon for the
applescript and one for eclipse so
can still keep the bare eclipse on
the dock.
Any suggestions? Am I going about this in completely the wrong way?
There is an alternate solution which involves replacing the executable that is run by MacOS X when the user launches the Eclipse application with a shell wrapper that sets up the environment.
Create an empty text file called "eclipse.sh" in the Eclipse application bundle directory /Applications/eclipse/Eclipse.app/Contents/MacOS.
Open the eclipse.sh in a text editor an enter the following contents:
#!/bin/sh
export ENV_VAR1=value
export ENV_VAR2=value
logger "`dirname \"$0\"`/eclipse"
exec "`dirname \"$0\"`/eclipse" $#
In the example ENV_VAR1 and ENV_VAR2 are the environment variables being set up. These variables will be visible to processes launched from within Eclipse. The logger command will just log the path of the eclipse executable to the system.log as a debugging aid.
In the Terminal set the executable flag of the shell script eclipse.sh, i.e.:
chmod +x /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse.sh
Open the Eclipse.app Info.plist and change the value for the key CFBundleExecutable from eclipse to eclipse.sh.
MacOS X does not automatically detect that the Eclipse.app's Info.plist has changed. Therefore you need to force update the LaunchService database in the Terminal by using the lsregister command:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -v -f /Applications/eclipse/Eclipse.app
The next time you launch Eclipse.app from the Dock or from the Finder the environment variables should be set.
I created the following:
alias start-eclipse='open /Applications/eclipse/Eclipse.app'
If you run start-eclipse from the command line, all env vars will be picked up. This way, you only need to maintain a single set of env vars across both command-line and eclipse environments.
Take a look at a related question: Environment variables in Mac OS X.
Basically, this involves the creation of a ~/.MacOSX/environment.plist file.
Log out and Log in for the environment.plist to get picked up by .App's
This worked perfectly in OS X Yosemite:
Open /Applications/Automator.
When the drop-down appears asking you what kind of document you want to create, choose "Application."
In the second-from-the-left list, double-click "Run Shell Script."
In the right side delete the "cat" that gets put there automatically, and replace it with this:
source ~/.bash_profile && /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse
Now go to File->Save, and save the application to your Applications directory. I named it "Eclipse" with a capital 'E' so as not to conflict with the "eclipse" directory I already had. For good measure, you can even give it the Eclipse icon by selecting the real eclipse app, pressing command-i, selecting the icon, pressing command-c, then selecting the automator "Eclipse" app, pressing command-i, selecting the icon, and pressing command-v.
Now you can open the app, or even drag it to your dock. Note that if you start it, the "real" eclipse will still show up in your dock as a separate icon, but you can't have everything. :)
sakra's answer above is awesome, except is doesn't automatically inherit your existing bash environment. To ensure eclipse.sh picks up your existing bash environment, modify eclipse.sh to use bash instead of sh and add a line to source your existing ~/.bash_profile thus:
#!/bin/bash
source ~/.bash_profile
logger "`dirname \"$0\"`/eclipse"
exec "`dirname \"$0\"`/eclipse" $#
None of the above worked for me. you have to set Eclipse -> Preferences -> Terminal -> Arguments set to --login
That will instruct Eclipse to login with your account just after opening Terminal.
See screenshot:
Reference: https://marketplace.eclipse.org/comment/4259#comment-4259
Link to Eclipse doesn't use the path set in .bashrc
Create simple script
#!/bin/bash
source /home/user/.environment_variables
/home/user/eclipse_cpp/eclipse -Duser.name="My Name"
2.
Next put your all system variables in file /home/user/.environment_variables (any file you want)
My looks like:
export COCOS_ROOT=/home/user/Projects/edukoala
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
3.
Now you can delete your variables in .bashrc and put line
source /home/user/.environment_variables
Everything works fine :)
As pointed out in https://github.com/atom/atom/issues/7045, the environment variables can be loaded automatically, without explicit source ~/.bash_profile by using
#!/usr/bin/env bash -l
instead of
#!/bin/bash
source ~/.bash_profile
after that, in both cases, follows
exec "`dirname \"$0\"`/eclipse" $#
It works great for me, thanks for all previous work.
After setting env variables in .bash_profile.
Simply open the application through terminal!
open /Application/{path/to/app}.app