LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 07-13-2022, 11:19 AM   #1
AlanRaczek
LQ Newbie
 
Registered: Mar 2019
Posts: 9

Rep: Reputation: Disabled
Passing a file to a shell script


I am trying to run a script (not created by me) and have some basic questions. Consider this command:

bash update_repo.sh ./delta_repo.tar.gz

When I run this I get:
tee: /opt/repo/update_repod.log no such file or directory
tar (child) ./delta_repo.tar.gz cannot open no such file or directory

So I am thinking something in the path is wrong or where I have the delta_repo.tar.gz is incorrect. I was curious
on what the ./<filename>. Especially what the ./ means.

Thanks.

...ar
 
Old 07-13-2022, 12:49 PM   #2
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,146
Blog Entries: 6

Rep: Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834
Quote:
./<filename>
In the current directory. You would use that if the current dir is not in your $PATH.

test.sh
Code:
#!/usr/bin/bash

echo "Hello world."
Code:
chmod u+x test.sh

test.sh
bash: test.sh: command not found

./test.sh
Hello world.
 
Old 07-13-2022, 03:44 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,759

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
Actually the . in ./<filename> is a shortcut for current working directory i.e the output when you execute the command pwd.
The output of pwd does not contain a trailing / and therefore you to to add it to separate the directory from the command/file you are trying to run or access.

linux only searches the environment path but not current working directory (i.e. where you are in the filesystem ) when trying to run a command so . (./) is used as a shortcut to specify the absolute path. On the other hand if a file is used as a command line argument as in your example the script does not need a ./ if the file is in the current working directory as that of the script you are running.

Your particular error "tee: /opt/repo/update_repod.log no such file or directory" maybe due to not having a subdirectory called repo within your /opt. Without knowing anything about this script, what it is supposed to do or delta_repo.tar.gz it is difficult to provide more specific answers.
 
Old 07-14-2022, 08:36 PM   #4
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
This command
Code:
bash update_repo.sh ./delta_repo.tar.gz
is running the script update_repo.sh with the argument (file name) './delta_repo.tar.gz'

Those errors are occurring because something within that script is encountering an error.

If you want actual help we would need to see the exact content of that script and what it does so the commands and the error could be parsed.
 
Old 07-14-2022, 09:34 PM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,009

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
As a side note to the good advice above, running an unknown script with zero knowledge on what it might do would not be a good suggestion IMHO

As mentioned above, maybe attach or display the script here and we can see if we can help you and advise what it does?
 
  


Reply



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
passing arguments from expect script to a shell script schoedel Programming 3 06-29-2013 10:59 AM
Passing arguments to shell script like perl script get-opts somupl86 Linux - Newbie 2 12-02-2010 11:14 PM
Passing args in terminal window is OK. but isn't when passing in GNOME launcher why? majrys1962 Debian 0 11-18-2008 06:00 PM
passing passing variable in Java as reference djgerbavore Programming 3 11-10-2004 02:18 PM
Passing variables from AWK script to my shell script BigLarry Programming 1 06-12-2004 04:32 AM

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

All times are GMT -5. The time now is 07:52 AM.

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
Open Source Consulting | Domain Registration