I am trying to do cd command and i can see there is not change in path after that,not knowing what is the reason
I checked workarounds available in internet telling to give whole path,use alias etc but nothing worked out ,when i try manually doing cd its working and i tried giving this command in other dummy script there its working
But in my shell script even if i create one director and try to change also its not happening,code is actually getting stuck there and not going to other lines
Please suggest me what else i can so with this
Related
Not sure if this is operator error or if I just don't understand enough of what I am trying to do.
I have created cleardl.sh and put it in ~/bin and have also added ~/bin into $PATH, when I run echo $PATH it shows that it was added correctly.
If I am in ~/bin I can run ./cleardl.sh and it runs like it should, but if I try to run it from anywhere else I get a file not found error.
I have tried to make an alias for it but this also doesn't work more than likely due to me not knowing how to do that either.
Any help is appreciated.
Edit:
Moving the file to /usr/local/bin did get it working but then I deleted it to do some other tests and it kept working So it was likely me not having all the things correct at the same time.
Thanks for your help
Can anyone tell me where my file may have gone after this command?
The file I'm missing is stats.cpp
And what is the correct command to move it from directory prog3a to prog3c?
Thank you.
Since you did not post the actual command you used I cannot tell you what happened to the file. What I can say is that unless you used the rm command, the file is not gone. Probably got its name changed if you cannot find it or it got moved somewhere else other than the intended destination.
The correct command you should use is
mv prog3a/stats.cpp prog3c/stats.cpp
This command should be run in the directory where both prog3a and prog3c folders exist (cd to it before running the command. This is assuming they're both inside the same directory).
A more specific answer can be provided if you tell us which command you initially ran specifically and the full paths of each folder.
Right now, I have shellScript.sh and test_me.py in a folder ABC/def. shellScript.sh calls test_me.py. I'm trying to call shellScript.sh from the ABC folder. So far, I keep on getting "No such file or directory" errors.
I've tried calling the python script from the shell script such as:
python /ABC/def/test_me.py
but this still gives me the same error.
How do I fix this?
Make sure your home directory starts by a capitalize H, if it does not (which is highly probable) your script won't work.
If the problem is not in the path or filename, then it could be in the way you are executing the shellScript.sh:
./shellScript.sh
might fix it provided you have the proper execute bit set on the script file. If not, try this:
sh /proper/path/to/shellScript.sh
If that does not fix it, then try to cd to the directory in the script before the python line:
cd /to/proper/folder
python test_me.py
First off I am very very new to shell scripting. I am trying to write a script that takes in one parameter and then copies a folder in a different directory naming it using the parameter. This is the current code that I have:
#!/bin/sh
cd /var/www/html/fbplugin/chrome
sudo mkdir temp/$1
sudo cp -rf "/var/www/html/fbplugin/chrome/fbplugin" "/var/www/html/fbplugin/chrome/temp/$1"
When I run this code it says can't cd to /var/www/html/fbplugin/chrome. I'm not sure why it is saying this because I know the directory exists. I have copied the line directly and it works in terminal. If anyone could help me out that would be great.
If it matters in order to run the script I am typing "sh build.sh"
If that directory really exists, then you must have executed that script with a different user (cron, webserver, etc).
Check the rights for that directory.
I don't know why you're getting the error about cd, but it looks like you could just use absolute paths throughout. That would solve the larger problem of the script working correctly.
Last week, when I am trying to install gcc_select on my macbook, I went through several commands,I did remember I just cd to a certain directory and made some modifications using the root. Everything seems fine, however, I found that when I open the terminal and trying to compile a program by using gcc or g++, it keeps saying that the "command not found".I have to manually to type the :" export PATH=$PATH:/Developer/usr/bin" in order to make the gcc or g++ command run.
My question is , is there anyone please tell me how to permanently change that, so that I don't need to type the same command again and again.
Append
export PATH=$PATH:/Developer/usr/bin
in the .profile file in your home directory. If it does not exit, create it. Better way would be the one user57368 gave in the comment though.