0

I had a software developed. And now my developer is no longer working with me. I have about 40 users on this, and it seems this thing is ran manually. Yet it was working for the users when they used their copy of it. Im so lost. Any help much appreciated.

His instructions say this:

script_run_scrapers.sh: bash script for run the ranks scrapers (googlerank, googlevideorank and youtuberank) via wget

sample for run 300 scrapers

./script_run_scrapers.sh 300 10

This is the code in the script:

max=$1
maxy=$2
while [ 1 ] ; do
    x=`ps -Af | grep wget | grep -c "path_to_web"`;
    echo $x;
    if [ $x -lt $max ] ; then
        r=$RANDOM;
        #echo $r;
        i=1;
        y=$(( $max - $x ));
        while [ $i -le $y ] ; do
            wget -O /dev/null -o /dev/null "http://127.0.0.1/path_to_web/googlescraper.php?max=$maxy"  2>&1 &
            i=$(( $i + 1 ));
        done;
    fi;
    sleep 5s;
done;

enter image description here

muru
  • 197,895
  • 55
  • 485
  • 740
  • 1
    What happens when you try to run the script? When you cd into the directory where the script is and then run ./script_run_scrapers.sh 300 10 in a terminal window, what shows on the screen? – Nick Weinberg May 08 '17 at 15:45
  • 2
    What does the screenshot have to do with anything? – muru May 08 '17 at 15:46
  • What is your question? Do you want to know how to run you shell-script? Then https://askubuntu.com/questions/38661/how-do-i-run-sh-files could help you. chmod +x needs the filename as additional argument (as it is telling you, that it needs one more argument). – David Georg Reichelt May 08 '17 at 15:48
  • Because that is as far as I have got with this. – Randy James May 08 '17 at 15:48
  • I havent been able to run the script. I am very new to this, just trying to get it to work again. My dev wont help me. – Randy James May 08 '17 at 16:09

1 Answers1

1

In order to make your script executable, you need to use chmod +x and specify the file you are modifying.

So

chmod +x script_run_scrapers.sh

As it stands you have just run

chmod +x

but not specified the file that is to be made executable.

You have also typed cd to change directory, but have not specified where you want to change directory to. For example :

cd /home/victor

will change directory to /home/victor/

I think what you are wanting to do is change into the directory that holds your script, then modify the permissions of your script so that is is executable, then execute it ?

Lets assume your script is in the directory /home/victor/

cd /home/victor/

chmod +x script_run_scrapers.sh

That only has to be done once, then all you have to do is execute it

./script_run_scrapers.sh 300 10

To check the current permission of the file, use ls -la

ls -la script_run_scrapers.sh
hatterman
  • 2,280
  • 2
  • 22
  • 33
  • root@LAPTOP-RG1ECSPS:~# cd root@LAPTOP-RG1ECSPS:~# chmod +x chmod: missing operand after ‘+x’ Try 'chmod --help' for more information. root@LAPTOP-RG1ECSPS:~# chmod +x script_run_scrapers.sh chmod: cannot access ‘script_run_scrapers.sh’: No such file or directory root@LAPTOP-RG1ECSPS:~# – Randy James May 08 '17 at 15:52
  • Like this cd C:\Users\Randy James\Desktop\

    chmod +x script_run_scrapers.sh

    – Randy James May 08 '17 at 16:02
  • root@LAPTOP-RG1ECSPS:~# cd C:\Users\Randy James\Desktop\

    chmod +x script_run_scrapers.sh

    bash: cd: C:UsersRandy: No such file or directory root@LAPTOP-RG1ECSPS:~# cd desktop bash: cd: desktop: No such file or directory root@LAPTOP-RG1ECSPS:~# cd

    – Randy James May 08 '17 at 16:03
  • cd C:\Users\Randy James\Desktop\ . This is a Windows directory structure, in linux you dont specify a drive letter, don't use the colon and the slashes are the other way. For example cd /home/victor/ – hatterman May 08 '17 at 16:10
  • like this? cd C/Users/Randy James/Desktop/ – Randy James May 08 '17 at 16:15
  • cd /Users/Randy James/Desktop/ – Randy James May 08 '17 at 16:16
  • root@LAPTOP-RG1ECSPS:~# cd /users/randy james/desktop/ bash: cd: /users/randy: No such file or directory – Randy James May 08 '17 at 16:22
  • Will the code change if i am using bash on ubuntu on windows? – Randy James May 08 '17 at 16:34
  • root@LAPTOP-RG1ECSPS:~# cd /mnt/c root@LAPTOP-RG1ECSPS:/mnt/c# chmod +x script_run_scrapers.sh root@LAPTOP-RG1ECSPS:/mnt/c# ./script_run_scrapers.sh 300 10 0 0 – Randy James May 08 '17 at 16:41
  • I did something!! – Randy James May 08 '17 at 16:52
  • 21 packages can be updated. 12 updates are security updates. root@LAPTOP-RG1ECSPS:~# cd /mnt/c/ root@LAPTOP-RG1ECSPS:/mnt/c# ./script_run_scrapers.sh 300 10 0 151 300 300 300 300 300 300 300 300 – Randy James May 08 '17 at 16:53
  • Your using bash on Ubuntu in windows ? Well you never said that .... – hatterman May 08 '17 at 19:41
  • Yes do you know what the developer meant with this part of the code./script_run_scrapers.sh 300 10 the 300 10 represent what? Its now making my software time out. – Randy James May 08 '17 at 23:22
  • So have you now got the script running ? Did you succesfully make it executable using chmod and get it running ? Assuming that you did, the first 2 lines of the code assign values to the variables 'max' and 'maxy'. In this case, 'max'=300 and 'maxy'=10. Those values are used while iterating through your loop. – hatterman May 09 '17 at 08:12
  • What is it, exactly, that you want to achieve ? What results are you expecting this code to produce ? I'm no bash expert, but the code looks like it is running a php script on the localhost (googlescraper.php). Does that script exist ? On a side note, why has your dev left ? (Think you might need to buy him/her a beer or get another dev in). – hatterman May 09 '17 at 08:21
  • I am running the script on my local machine when I believe it must be run through my server using bash. Thanks for the tip about maxy, and max. I added those into the script and it just produced 0's. My developer left because he became unresponsive, and left me hanging on the project. I have around 40 beta users on this software. – Randy James May 09 '17 at 17:21
  • And have been trying to get it up and running for a few months now. It is a tool that scrapes the web for videos positions in google, google video, and youtube. The selling point is that it does not need manual keyword entry, as all you have to do is input a channel and it gets the positions. Ive been through 5 developers from freelancer, and they cant fix the issue. So I am learning how to do it myself. I contacted hostgator. And will be trying this next. http://support.hostgator.com/articles/hosting-guide/lets-get-started/how-do-i-get-and-use-ssh-access – Randy James May 09 '17 at 17:21
  • Not sure what you added into the script as Maxy and max are already there. All things considered I am going to gracefully bow out and suggest that you get a new dev in or your old dev back. Sorry I can't help. – hatterman May 09 '17 at 19:49