0

ss4

Usage: ss4 <filename>

chmod 744 $1

$1

Hi this is my script , after executing it i am getting error as "./ss4: line 6: ss1: command not found"

HELP me.

Edited by rohan1111

7
Contributors
10
Replies
42
Views
3 Years
Discussion Span
Last Post by rohan1111
0

hi tapananand my sript is about adding permission for execution of script, instead of every time giving command "chmod 744 <filename>" for new shell scripts for adding execute permission, using this program i will send the file name as input that will store in $1 and it should change the permission and show the output.

My script is 'ss4'

---->

ss4

Usage: ss4 <filename>

chmod 744 $1

$1

----->

i execute this script like this

$ ./ss4 <filename>

after execution i am getting error as "./ss4: line 6: ss1: command not found"

0

First of all put code using code button. Secondly when putting code just put the code. What is this Usage and all. We don't need this. Your script is not clear at all. What is line 6? Nothing is clear. You'll struggle to get answers here if you post like this.

0

I'm taking a shot in the dark, because I'm not sure where line 6 is, but it looks like the problem is this: $1. That will not run the program. You should instead use ./$1.

Edited by Hiroshe

0

Use this python script

#!/usr/bin/env python
#-*-coding: utf8-*-
import argparse
import os

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='chmod files to mode 744')
    parser.add_argument('files', nargs='+', metavar='FILES')
    args = parser.parse_args()
    for filename in args.files:
        os.chmod(filename, 0744)
0

I assume this is a shell script. When you execute the argument as a command, it has to be found in the system's PATH environment. Try ./$1 instead. That tells the shell to look for the command (argument) in the local directory, where you executed the ss4 command.

0

It's kind of bothering me now (I don't write bash scripts too too often, and they are generally for simple tasks). If we use ./$1 to execute the argument, then we are asumming that $1 is a relative path. Shouldn't there be a way to execute it given a path that may either be absolute or relative? I mean, we can start pulling out the heavier logic and check for a leading /, however I feel there should be a simpler way.

0

You could also just call the interpreter first. For instance, if we know that "$1" is a shell script:

/bin/sh $1

or

/bin/bash $1

I hope rohan1111 gets back to us about what the problem was. If the script really is essentially (as others have guessed) just:

chmod 744 $1
$1

...then I think you are all on the right track.

0

Hi "tapananand" i am new to posting of my script and learning just now, thanks for your comments, suggestions. your suggestions are some times scaring me.

Hi "Hiroshe & rubberman" i tried with your suggestions and it worked out for me.

Thank to all for helping me out

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.